2015年12月20日 星期日

[How to] Setup Samba in Linux

Let see my setup environment:

Server:
- Arch Linux  4.2.5-1-ARCH
- samba Version 4.3.3

Client:
Same as server

Network Setup:
Internet - Server(192.168.1) - Router(192.168.2) - Clients

= = =
Setup procedure:
1. Installation: (For both server and client)

#pacman -Syu samba

2. Setup config

I have made a config file to share the server /tmp folder and allow only me and home subnet only.

= = =
[global]
   workgroup = WORKGROUP
   server string = Samba Server
   hosts allow = 192.168.1. 127.
   printcap name = /etc/printcap
   load printers = yes
   log file = /var/log/samba/%m.log
   max log size = 50
   security = user
   dns proxy = no
   invalid users = nobody root
   map to guest = Bad User
   max connections = 10
[homes]
   comment = Home Directories
   browseable = no
   writable = yes
[tmp]
   comment = Temporary file space
   path = /tmp
   valid users = your_user
   public = no
   writable = yes

= = =

Configure your user to samba, and enter the user password.
#pdbedit -a -u your_user

3. Run

In server:
#systemctl enable smbd.service

If you also need netbios support:
#systemctl enable nmbd.service 

Server side should be more or less ready and change to Client

Client:

Just test the samba connection to the server

user@localhost:~$ smbclient -L 192.168.1.1 -U your_user
smbclient: Can't load /etc/samba/smb.conf - run testparm to debug it
Enter your_user's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.3]

        Sharename       Type      Comment
        ---------       ----      -------
        tmp             Disk      Temporary file space
        IPC$            IPC       IPC Service (Samba Server)
        your_user       Disk      Home Directories
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.3]

        Server               Comment
        ---------            -------
        LOCALHOST            Samba Server

        Workgroup            Master
        ---------            -------
        WORKGROUP            LOCALHOST



If you see similar output, the connection should be ready and you can mount remote samba drive

#mount -t cifs //LOCALHOST/tmp /mnt -o user=your_user,workgroup=WORKGROUP,ip=192.168.1.1
password:


Nice and Done!!

2015年12月16日 星期三

[How To] Fix Tearing on Linux Intel Graphics

#cat /etc/X11/xorg.conf.d/20-intel.conf

Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"

   Option      "TearFree"    "true"
EndSection


Works well on my arch linux machine. No tearing now in watching One Punch Man~ Cheers

2015年12月15日 星期二

rsync - a simple backup command

If you want to backup something just use the following command

$rsync -au /source/path/* /dest/path/folder 

In case after some days your source path have new files or some changes, just recall the command and it can simply update the destination folder to sync everything.

2015年10月23日 星期五

Alexa - a web page to show how pofitable of a web page

Alexa - http://www.alexa.com/ In internet point of view, browsing count means profit. This page can show the ranking of amount of access of a page. That is for simply, how profitable for the page is and the efficiency of putting advertisement there.

2015年10月2日 星期五

How To Download content in Python using urllib2 with example

I am working on a project that needs to download content from web and parse it's data in Python. I have done some modules which is useful in downloading stuff. Or I just share the source code.

= = =
#!/usr/bin/python2
import time
import urllib2

__user_agent = "Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0"

def url_req(url, cookie=None, max_retry=3, retry_wait_s=5):
    r_html = None
    retry = 0

    while 1 :
        if (retry == max_retry):
            break

        data_req = urllib2.Request(url)

        #cookie support
        data_req.add_header('User-Agent', __user_agent)
        if cookie is not None:
            data_req.add_header('Cookie', cookie)

        try:
            data_handler = urllib2.urlopen(data_req)
        except urllib2.URLError as e:
            print (e.reason)
            time.sleep(retry_wait_s)
            retry = retry+1
            continue
        except:
            pass
            time.sleep(retry_wait_s)
            retry = retry+1
            continue

        try: r_html = data_handler.read()
        except urllib2.URLError as e:
            print (e.reason)
            time.sleep(retry_wait_s)
            retry = retry+1



            r_html = None
            continue
        break

    return r_html

2015年10月1日 星期四

How To Create Windows Bootable USB on Linux

You know when working on Linux, there is still some constraint that is not easy to overcome. This time I would like to upgrade BIOS for my old Thinkpad. It seems the best choice with less risk is installing a Windows on another harddrive and upgrade it. But my laptop do not come with a DVD-ROM and also I don't have any external one. So I go for USB solution.

For all Linux bootable iso can be made through command "dd" but it doesn't work for Windows Disc as the MBR is different. So what I do is make use of a tools called "ms-sys"

Software Tools needed
Windows ISO (You should know how to get it)
gparted (partition the usb)
ms-sys

Steps:
1. use gparted to clear all partition on usb drive
2. use gparted to create NTFS partition on USB, set the partition as bootable
3. mount Windows ISO, copy all files from mount point to USB. "sync"
4. Call the magic "sudo ms-sys -7 /dev/sdX" to write the MBR to USB. I used Windows 7 as the example or you may read the help of ms-sys
5. unmount everything
6. Nice and Done and you got a bootable USB

Go Go Flash Bios!!

2015年8月18日 星期二

[How to] Python Create worker threads in Multi-processing Application

In case of processing large amount of data, multi-processing / multi-threading is a good way to speed up the whole process. In Python, some of the library is not thread safe, So using a multi processing as an example for the simple application

For simply, just look at the code:

2015年7月25日 星期六

Review of Android X86 4.4R3

Android X86 (http://www.android-x86.org/) have been release of the new version of official release. The new version is Android 4.4_R3 which is the third release of Android 4.4. If you would like to test on the lollipop you may try the beta release.

Let's see my review:

Setup:
Lenovo Thinkpad X61 (Intel T8300 4GB DDR2)
Arch Linux Kernel - 4.1.2-2-ARCH

Review:
Although it is the release version, it is easy for me to find bugs / non-implemented part on the software.

See whats the improvment:
1. Bug fix and it works on my thinkpad now. Last version is not supported
2. For native run, seems everything works fine

Please find the list below:
1. No multi screen support (May be too harsh to an open source software)
2. Sometimes the text in android UI will come to garbage words. Toggle the UI will come back to normal
3. Screen rotation breaks the usage as for PC, no screen rotation is needed. Makes me like handicap when the screen rotate
4. Tested on KVM. But I still can't make OpenGL work on it.

Conclusion:
The result is positive for the new release and it run most applications stablely. It is not far away from daily usage. I am sure when this project come to a stable version, this will come to a evolution to the PC market that people will switch to use Android-X86 rather than Windows in their PC. Or may be someday Microsoft will be down because of this.


2015年7月18日 星期六

2015年7月9日 星期四

[How To] Install openwrt in Xiaomi Mini Router

Just install openwrt in my new Xiaomi mini router. First of all, I am not that trust China's product that do not have backdoor and tracking. So I choose the opensource openwrt firmware. The flashing procedure I have make a copy from site for my reference.

I have test for a few firmware
9 July, 2015
- Xiaomi default firmware
    never tested
- Openwrt CHAOS CALMER (15.05 RC2)
    5GHz and 2.4GHz works fine but the power is not strong as PandoraBox
- Openwrt CHAOS CALMER Trunk
    Only 2.4GHz, 5GHz not work
- Pandora Box Openwrt (Close Source) r1024
    I am not sure if I am black luck. 5GHz and 2.4GHz works great from the very beginning but it makes the 5GHz chip (mt7612E) burn out after use for a few hours. (Please leave comments if you have the same case as I am. I even flash every firmware and can't make the 5GHz chip work and it is dead. The router can work only with mt7620A with 802.11N 2T2R 300M (Better than a rubbish)

The following is the guide can change from default firmware to any third party firmware

= = =
1.      First off before anything else, install Chrome and its translator plug-in for all 3 Chinese language.
2.      Plug in power and Ethernet cable to one of the Ethernet ports
3.      Direct browser to 192.168.31.1.  Unfortunately I could not get Chrome to translate, likely because translation requires internet access, which has not been set up yet.
4.      The first screen will appear.  Press blue button to get to next screen.

5.      The next screen sets up the wifi network name and password.  Note that the wifi password is also used later for access to the browser page (192.168.31.1).  


6.      Once you have set this up, plug in WAN cable for access to internet.  Internet access also enables the Chrome translation and you can confirm that the router works properly before proceeding.
7.      The next few steps involve first loading the development version of the firmware, then loading a firmware version which provides SSH access with the last step being loading the OpenWRT firmware onto the router
8.      Apparently loading the development version ofthe firmware voids warranty, so beware. Development version can be obtained from http://www1.miwifi.com/miwifi_download.html.  Point to the mini router to get the correct firmware/software.  At the same time you can also download the PC Client (although I don't recommend this) and also one of either iOS or Android app.  You will NEED one of these to complete the steps. The development ROM that I downloaded was named miwifi_r1cm_all_ace8a_0.6.40.bin.  Apparently the development ROM that is used is important because some of the ROMs may not allow the next step of flashing the SSH firmware.  The older ROMs can be found here http://www.miui.com/thread-1776173-1-1.html.  Try to use the development ROM that has been proven to allow the next step of the process



9.      The above downloads the Chinese versions of PCClient and iOS/Android apps.  To get the translated software follow these links. The iOS/Android are necessary because they are used to link the hardware to the miwifi account that you are about to set up.  Without the link, the SSH version of the ROM(and SSH password) will not be available
http://en.miui.com/forum.php?mod=viewthread&tid=55706(portable version – although I have not used)
10.  Create and activate a new account at Xiaomi  https://account.xiaomi.com/pass/register.  When you have setup the account and logged in, remember the User ID.  You will note that there is no device associated with the account.  The association has to be done via theiOS/Android app.  Unfortunately there does not seem to be a way to do that via the PC Client, which is why I do not recommend installing this.
11.  Using your iOS or Android device, open the app.  Login using the ID and password in the step above.  The account then recognises the Xiaomi mini router device. This is required for the SSH firmware.
12.  To get the SSH firmware proceed to http://www1.miwifi.com/miwifi_open.html.  Halfway down the page there is a SSH button

13.  Click on the button and sign into the Xiaomi account when requested.  After signing in you will be presented with a page to download the SSH firmware.  Also note the SSH password for root user in the middle of the page.  The SSH firmware will have the name miwifi_ssh.bin

14.  Now that you have all the firmware, it is just a matter of flashing in the correct sequence. First off, get an empty USB drive and format to FAT or FAT32.  I tried unsuccessfully using drives less than 2GB.  In the end, I had to use a 2GBdrive, although the firmware(s) were a lot smaller in size.
15.  Copy the development firmware into the USBdrive.  (Did I tell you to delete all other content? – Please do).  Rename the development firmware to miwifi.bin.  This is important
16.  The development firmware and SSH firmware flash both follows the same procedure
a.      Pull the power from router, at the router
b.     Plug USB drive into router.  
c.      Press reset button (in the hole to the left ofthe USB drive)
d.     While holding down the reset button, plug in thepower.  The orange light in front of the router will remain steady for a short while before it starts flashing
e.     Once the orange light starts flashing, releasethe reset button and sit back until the light in front of the router turns blue.  Also if there are indicator lights on your USB drive, they will flash as the drive is being read.  If the orange light does not flash, try with another USB drive and confirm that the drive is formatted to FAT or FAT32.
17.  The router can be re-set up between each flash just to confirm that it is working, but I generally just flash the firmwares one after the other.  
18.  I also tend to delete all the contents from the USB drive between flash.  I don't know the impact of not deleting, but better safe than wrong.  
19.  The SSH firmware do not have to be renamed for the flash.  Just keep the name as miwifi_ssh.bin
20.  Once the SSH firmware has been successfully flashed, confirm SSH via putty and also Winscp. Port is 22, username “root” and password as noted from step 13.
21.  The OpenWRT firmware will need to be downloaded from http://downloads.openwrt.org.cn/PandoraBox/Xiaomi-Mini-R1CM/.  I used the latest version PandoraBox-ralink-xiaomi-mini-r583-20140827.bin.  Once downloaded, rename the file to 20140827.bin
22.  Open Winscp and connect to the router using 192.168.31.1, Port 22, username root and password as from step 13.  Transfer 20140827.bin to the /tmp directory.The tmp directory is in the root of the drive
23.  Open putty and connect to the router using 192.168.31.1, Port 22.  Enter root as username and password as above
24.  Change to the tmp directory - cd /tmp
25.  Confirm that you have the right directory by doing a directory listing (ls –l) and confirming that the 20140827.bin file is listed
26.  Finally flash the OpenWRT firmware using puttycommand
mtd -r write /tmp/20140703.bin firmware
27.  The router will reboot once it has beensuccessfully flashed.
28.  Access the OpenWRT router via 192.168.1.1 on your browser.  Unfortunately the default pages are in Chinese.  Default account usernamewill be “root” and password “admin”
29.  Once in, ignore the quick guide setup and navigate to the language page to change language to English.  On the left, third choice down, first subchoice and third tab page with the first settings.  Click on green button on bottom left to “Save and Apply”.   It may be necessary to reboot, but I did not have to.

2015年7月1日 星期三

[How To] identify a ssh bash session in linux

Very simple just edit .bash_profile

= = =
#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc
skip_x="0"

if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
    echo "THIS IS AN SSH SESSION"
    skip_x="1"
fi


#check if x started


ps aux | grep tty |grep startx 2>&1 > /dev/null
if [ "$?" == "0" ]; then
    skip_x="1"
fi

if [ "$skip_x" == "0" ]; then
    exec startx
fi

= = =

2015年6月7日 星期日

[How To] Lenovo Thinkpad run in full speed with battery removed in linux

After using for nearly 9 years (since 2006) of my thinkpad X60 battery. It cannot be charged in a Saturday. As lenovo will limit the CPU speed when the notebook removed the battery. It decrease the performance a lot when battery removed. So for this case, I have searched for a solution.

Let's see my setup:
Lenovo Thinkpad X61 T8300 2.4GHz

How to override it:

When the battery was removed, Lenovo limit the CPU speed in bios, for this case, setting the  scaling_max_freq will not work.

#To see which frequency of the CPU you can set, you may:
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
2401000 2400000 2000000 1600000 1200000 800000


#So To override the BIOS limit:
echo 1 > /sys/module/processor/parameters/ignore_ppc

#replace the 2400000 for your max CPU speed
for x in /sys/devices/system/cpu/cpu[0-1]/cpufreq/;do
  echo 2400000 > $x/scaling_max_freq
done



Very nice and done.

Just a reminder that when override the bios limit may harm the mainboard. For this case, it is highly recommand to use i7z or phc-intel to lower the voltage of the processors (I have set it before that). It may have less chance for overloading the mainboard.

Cheers.

= = =
reference:
http://blog.patshead.com/2013/04/my-bios-is-limiting-my-cpu-clock-speed.html

2015年6月6日 星期六

[How To] Lower the heat of your computer without any hardware changes in Windows

[How To] Lower the heat of your computer without any hardware changes

Recently I have used the computer of my wife. It is not a fast computer but the computer case blow out hot wind and make the bedroom very hot after starting the computer. Even if I start the speedstep on CPU (or CnQ for AMD processors). The hot wind still blow out from the computer.

And I have found a solution by using a software called "Throttle Stop" you may find it in the following link:

http://www.techpowerup.com/downloads/2288/throttlestop-6-00/

And for the right setting, you also need the following software too:
hwmonitor: http://www.cpuid.com/softwares/hwmonitor.html
 Helps to monitor the voltage as well as the CPU temperature

and

intelburntest easy to find in google
Helps to fullload your CPU to test the stability of your computer

What you need to do is to undervolt of the CPU power and test for the stability. It will not harm on any of the performance.

1. Start intelburntest, hwmonitor and Throttle Stop
2. Start intelburntest
3. in Throttle Stop, lower the VID by pressing the down arrow.
4. If your computer freeze up, start from 1 but increase a little of the last value
5. If intelburntest can pass for some testes, your computer should be more or less stable.
6. Run " Throttle Stop" at start up.


The main advantage for undervolt not only the heat. But also the power consumption of your computer and also the life of electric component on the mainboard. Also, undervolt can help CPU to emmit less heat and can help to slower the CPU fan for less noice. Few steps for more advantages. Why not do it.

My Intel Core 2 6420 undervolt during fullload from 1.35v to 1.1875v

 Cheers for less heat and save the earth

2015年5月23日 星期六

[How To] turn arch linux box to a wireless Access Point in the simplest way

Access point setting may be a little difficult for general linux user, I would like to introduce a one step way to use your linux box with a USB wifi dongle to change it to a wireless AP

1. Identify your USB wifi dongle support AP mode or not.
In order to turn your USB wifi to Access Point, your USB dongle must support AP Mode. you may check if it is supported by following:

$iw list
Wiphy phy1
    max # scan SSIDs: 4
    max scan IEs length: 2285 bytes
    Retry short limit: 7
    Retry long limit: 4
    Coverage class: 0 (up to 0m)
    Device supports RSN-IBSS.
    Supported Ciphers:
        * WEP40 (00-0f-ac:1)
        * WEP104 (00-0f-ac:5)
        * TKIP (00-0f-ac:2)
        * CCMP (00-0f-ac:4)
        * 00-0f-ac:10
        * GCMP (00-0f-ac:8)
        * 00-0f-ac:9
        * CMAC (00-0f-ac:6)
        * 00-0f-ac:13
        * 00-0f-ac:11
        * 00-0f-ac:12
    Available Antennas: TX 0 RX 0
    Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * monitor
         * mesh point
                  ...

 If you plug in your usb dongle and the Supported Interface modes do not have the "AP" mode, you need another usb module. Most likely for my personsal recommendation Atheros Chipset is a good choice.

2. Introduce to you a create_ap script. You may find it in the following link:
https://bbs.archlinux.org/viewtopic.php?pid=1269258

or from AUR
https://aur.archlinux.org/packages/create_ap/

Just install it and with the dependencies.

Just simply run a command

#create_ap wlan0 eth0 MyAccessPoint MyPassPhrase

And it is Done!! How come it is so easy.

There is a word for Chinese People "前人種樹後人蔭" "People plant trees, childen cools under tree"

Thanks for open source

2015年5月19日 星期二

[How to] Block ssh brute-force attack using sshguard in linux


In case your Linux box have provided a ssh function and connect to a public internet IP directly, in most case you will face a lot of brute-force attack. For this case, sshguard can help to lower the rate of the attack.

How it works
For simply, sshguard read logs from sshd and block suspicious attack by iptables.

In order to view if you are being attacked:
$journalctl -axe
...
 5▒▒▒ 19 12:28:10 localhost sshd[22109]: Connection closed by 70.60.248.30 [preauth] <==== Port Scan
 5▒▒▒ 19 12:28:34 localhost sshd[22111]: Did not receive identification string from 195.154.55.58
 5▒▒▒ 19 12:28:35 localhost sshd[22112]: Invalid user ubnt from 195.154.55.58
 5▒▒▒ 19 12:28:35 localhost sshd[22112]: input_userauth_request: invalid user ubnt [preauth]
 5▒▒▒ 19 12:28:36 localhost sshd[22112]: pam_tally(sshd:auth): pam_get_uid; no such user
 5▒▒▒ 19 12:28:36 localhost sshd[22112]: pam_unix(sshd:auth): check pass; user unknown
 5▒▒▒ 19 12:28:36 localhost sshd[22112]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhos
 5▒▒▒ 19 12:28:38 localhost sshd[22112]: Failed password for invalid user ubnt from 195.154.55.58 port 54126 ssh2
 5▒▒▒ 19 12:28:38 localhost sshd[22112]: error: Received disconnect from 195.154.55.58: 3: com.jcraft.jsch.JSchException: Auth
 5▒▒▒ 19 12:28:38 localhost sshd[22112]: Disconnected from 195.154.55.58 [preauth]
 5▒▒▒ 19 12:28:39 localhost sshd[22115]: Invalid user admin from 195.154.55.58
 5▒▒▒ 19 12:28:39 localhost sshd[22115]: input_userauth_request: invalid user admin [preauth]
 5▒▒▒ 19 12:28:40 localhost sshd[22115]: pam_tally(sshd:auth): pam_get_uid; no such user <=== Attack
 5▒▒▒ 19 12:28:40 localhost sshd[22115]: pam_unix(sshd:auth): check pass; user unknown
 5▒▒▒ 19 12:28:40 localhost sshd[22115]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhos
 5▒▒▒ 19 12:28:42 localhost sshd[22115]: Failed password for invalid user admin from 195.154.55.58 port 51840 ssh2
 5▒▒▒ 19 12:28:43 localhost sshd[22115]: error: Received disconnect from 195.154.55.58: 3: com.jcraft.jsch.JSchException: Auth
 5▒▒▒ 19 12:28:43 localhost sshd[22115]: Disconnected from 195.154.55.58 [preauth]
 5▒▒▒ 19 12:28:44 localhost sshd[22117]: pam_tally(sshd:auth): Tally overflowed for user root <=== Attack
 5▒▒▒ 19 12:28:44 localhost sshd[22117]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhos
 5▒▒▒ 19 12:28:46 localhost sshd[22117]: Failed password for root from 195.154.55.58 port 54190 ssh2 <=== Attack

... 

Installation

Very simple
# pacman -S sshguard
# iptables -N sshguard
# iptables -A INPUT -p tcp --dport 22 -j sshguard
# iptables-save > /etc/iptables/iptables.rules

# systemctl start sshguard.service
# systemctl enable sshguard.service


And you may find from the log
$journalctl -axe 
 5▒▒▒ 19 12:28:46 localhost sshguard[26588]: Blocking 195.154.55.58:4 for >630secs: 40 danger in 4 attacks over 12 seconds (all 

Nice and done 

2015年5月4日 星期一

Android X86 native experience - Android-x86 4.4r2

Android X86 is a project that can run android natively on X86 computer. I have downloaded and tested the latest release of "Android-x86 4.4r2" which was released on 1Jan 2015, as live CD. The experience is as follows:

1. Hardware
- Lenovo Thinkpad X61 (intel T8300, i965 4GB DDR2, ABGN4965)
- Desktop Computer (intel core 2 duo 6420, G33, 4GB DDR2, AMD HD4670)

2. Testing
It is strange that the laptop gives a very poor experience that the OS crash on the first screen of checking wifi status during inputing the Google Account. I have tested for a couple of times and it still not work. Seems cannot found a solution on web yet. I have tried to use a USB wifi and the issue is still the same.

For the Desktop computer, it is strange that everything works out of box.
Performance is great, very fast and no a little lag.
CPU works great with Speedstep
Graphics card works well with acclaration
Most app works

Just wanna know if it support MCE remote, or I will buy one or the android x86 media center.

= = =
Download Link:
http://www.android-x86.org/

2015年5月2日 星期六

[How to] Fix the kernel module issues for VirtualBox

As some of the linux users may face issues related to kernel modules, just would like to document how I fix the issue

I was face the issue on the log

VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterface, interface IHostNetworkInterface
VBoxManage: error: Context: "int handleCreate(HandlerArg*, int, int*)" at line 66 of file VBoxManageHostonly.cpp


To fix it, just load all kernel modules at boot up

# cat /etc/modules-load.d/virtualbox.conf
vboxnetadp
vboxnetflt
vboxpci
vboxdrv





= = =
Nice and Done

2015年4月11日 星期六

[How To] Speed up GUI for old Mac

Currently, there was a new release of OSX Version 10.10 Yosemite. But for some of the old Mac they equip with 2GB of memory and Core 2 CPU that may harm performance if come with those fancy UI. Disable those UI can boost system performance. Please find the tools below:

1. TinkerTool
http://www.bresink.com/osx/TinkerTool.html

With this tool, you can disable (some of) the animation effects

2. Beamoff (For Virtualbox and VMware users)
https://github.com/JasF/beamoff
https://www.youtube.com/watch?v=kDjirnJcanw
http://www.insanelymac.com/forum/topic/302424-yosemite-on-vmware-unusable/

By adding beamoff on startup, UI speed up alot and become smooth

2015年4月9日 星期四

[How To] Dump Certificates of ssl servers using OpenSSL

Need not explain much but read the command output.

The chain of certs can be shown on the list that server pass to clients. It can help to troubleshoot the issues related to ssl connection.

Just a note that this is not work for SSH as they are not sharing a similar protocol

= = =

$ openssl s_client -connect www.google.com:443 -showcerts
CONNECTED(00000003)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
   i:/C=US/O=Google Inc/CN=Google Internet Authority G2
-----BEGIN CERTIFICATE-----
MIIEdjCCA16gAwIBAgIIOPbIrrvyFtIwDQYJKoZIhvcNAQEFBQAwSTELMAkGA1UE
BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxJTAjBgNVBAMTHEdvb2dsZSBJbnRl
cm5ldCBBdXRob3JpdHkgRzIwHhcNMTUwMzI1MTUyNTE0WhcNMTUwNjIzMDAwMDAw
WjBoMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwN
TW91bnRhaW4gVmlldzETMBEGA1UECgwKR29vZ2xlIEluYzEXMBUGA1UEAwwOd3d3
Lmdvb2dsZS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCSTWLd
zWsBLTP2zxKl/WKRtJCGerseT381b6i71CRADCg+57sU2o0SaCOYFKSQ99iOul6j
qe2N/ua2/4QUBalk1HsfdttvOaaZD9AkBgJI+oiVgCcdbdpqet6xU4QlJo+qjC2C
SGXaPzD3jUiIfUyQ2G8KipXwqcyVG3Vi/JjskdEywclBgYIEVlK/UQ01fxeSIBEm
3yMM12vKWLNnowCI5mBv57gCZV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oWMPRfwCvocWvk+QIDAQABo4HwMIHtMB8GA1UdIwQYMBaAFEjm
aPkr0rKV10fYIyAQTzOYkJ/UMB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrM
TjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjA6BgNVHR8EMzAxMC+g
LaArhilodHRwOi8vY3JsLmdlb3RydXN0LmNvbS9jcmxzL3NlY3VyZWNhLmNybDBO
BgNVHSAERzBFMEMGBFUdIAAwOzA5BggrBgEFBQcCARYtaHR0cHM6Ly93d3cuZ2Vv
dHJ1c3QuY29tL3Jlc291cmNlcy9yZXBvc2l0b3J5MA0GCSqGSIb3DQEBBQUAA4GB
AHbhEm5OSxYShjAGsoEIz/AIx8dxfmbuwu3UOx//8PDITtZDOLC5MH0Y0FWDomrL
NhGc6Ehmo21/uBPUR/6LWlxz/K7ZGzIZOKuXNBSqltLroxwUCEm2u+WR74M26x1W
b8ravHNjkOR/ez4iyz0H7V84dJzjA1BOoa+Y7mHyhD8S
-----END CERTIFICATE-----
---
Server certificate
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=www.google.com
issuer=/C=US/O=Google Inc/CN=Google Internet Authority G2
---
No client certificate CA names sent
---
SSL handshake has read 3719 bytes and written 643 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
    Session-ID: 8098FDAE0A745395D661B7F5F23BBFB4E49A6CAE82F85905660C426B5795B4F0
    Session-ID-ctx:
    Master-Key: 4C2D4FADFD3388D40CC20F71C4AB59D27646FB38DB877AFBEB4E5B46F65E167B                                             C222CC7E45CB7E6423F48DA13E156E78
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 100800 (seconds)
    TLS session ticket:
    0000 - 79 21 bf 55 8b b8 bc 78-3f ba ab ce 71 34 8e 4f   y!.U...x?...q4.O
    0010 - a8 13 0d 13 3c cb 66 8b-81 93 9a 46 2f 91 a9 06   ....<.f....F/...
    0020 - d3 6b fa 30 81 2a 5c 08-8a 47 72 1f e1 4f f6 3a   .k.0.*\..Gr..O.:
    0030 - e1 b2 f4 09 8c 7a 80 35-90 e8 6c ee 14 f6 cc 38   .....z.5..l....8
    0040 - ec 31 c8 fe b6 00 13 31-4b a8 d8 0d 96 fc ff 9d   .1.....1K.......
    0050 - 2c 26 13 e1 a2 11 d1 b2-ca 11 16 d0 9c 40 fb a3   ,&...........@..
    0060 - 64 ab b0 9c ab c1 6e be-e1 cd 16 69 8f 12 89 b0   d.....n....i....
    0070 - a9 88 2c dd d6 ab 57 0a-64 b8 e9 98 0b 4a 0f e3   ..,...W.d....J..
    0080 - d3 64 fc 0e 42 2c c7 7d-00 bc 26 c0 18 42 de 15   .d..B,.}..&..B..
    0090 - ec e6 e6 4b 3f e6 f5 bf-a9 d9 05 70 bf 2c ad 4a   ...K?......p.,.J
    00a0 - 7a b1 95 28                                       z..(

    Start Time: 1428543793
    Timeout   : 300 (sec)
    Verify return code: 20 (unable to get local issuer certificate)
---
read:errno=0


2015年4月3日 星期五

[How To] Watch youtube using MPlayer

Mplayer is a very fast, low resources usage mplayer. It can be use to browse youtube. It is very good for some old computer.

Just run

$mplayer "$(youtube-dl -g http://www.youtube.com/watch?v=QCuq0_nY3Xk)"

2015年3月27日 星期五

ppsspp - Best linux psp emulator

Just have a test on ppsspp. By setting the frame skip and the controller, I can play psp games on my old Thinkpad X61. Nearly no other configuration is needed. I can play with the rom smoothly on my linux computer.

Spec:
T8300 with X3100 onboard

There is less games on linux machines but I am sure ppsspp can give some fun to those who work alot on linux.

2015年3月21日 星期六

[How to] Setup Chinese Input Method on Linux - SCIM

SCIM is a very good Chinese input program for Linux, exspecially for 速成 (Chinese Quick) Method. Setup is very simple in arch linux

1. Install Package
# pacman -S scim scim-table

2. To enable it in startup
$ vim ~/.xinitrc
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
scim -d


exec startlxde

Sometimes it is not work for reload setting on the tray icon. But reboot computer can help.

2015年3月16日 星期一

New Computer - migrate arch linux from AMD to intel

For years my computer is used, it was found dead after 7 years of working of my AMD Computer. After recover from sadness, I bought new parts to fix it. As the original one was using DDR2 which is quite outdated, I bought a new (not means fast) CPU and mainboard.

Let see the migration spec:
Original Config:
AMD Athlon II X2 240e
J&W Nvidia Geforce 8200 Mainboard
2GB x4 DDR2 RAM
GPU: nvidia onboard

New Config:
Intel Pentium G3258
Asrock B85 Mainboard
8GB x1 DDR3 RAM
GPU: intel onboard

Software:
Arch Linux 3.18.6-ARCH 64bit

After connect everything, computer bootup as usual. It boot up successfully to console user login.

The following is not work:
1. X
2. network

For the network part as the interface index was changed, just amend the configuration on netctl, the dnsmasq (dhcp server and dns provider) and dhcp client and everything works great. Just a reminder that the service of original setting was still running, and these services should be stopped.

For X windows, as I original was using the open-source driver xf86, what I need to do is uninstall nouveau, remove all the configurations and install package "xf86-video-intel" from pacman and it works!!


2015年3月15日 星期日

[How To] Bridge network interfaces using netctl

There are some ways to bridge network interfaces. The most popular one is "brctl". Other than brctl and we can use netctl to preform this task. relativly easy with easier settings.

1. Create a configuration file
# cat /etc/netctl/bridge
Description="Example Bridge connection" 
Interface=br0 
Connection=bridge 
BindsToInterfaces=(enp3s0 snp3s1) 
IP=static 
Address='192.168.1.1/24' 
#Gateway='192.168.10.200' 
## Ignore (R)STP and immediately activate the bridge SkipForwardingDelay=yes 

2. Just start it
# netctl start bridge

3. If it works fine, just enable it during boot
# netctl enable bridge

Nice and done.

a good reminder that the interfaces in the bridge should be disable the DHCP settings. 

2015年3月13日 星期五

Marvel App - An Mobile Application prototype generator

https://marvelapp.com/

This is a awesome site that can generate an iOS application from pictures on Dropbox. It's good for generating prototype of mobile application.


2015年3月11日 星期三

nbench - a simple computer benchmark tools for linux

nbench is a very small program that can benchmark a device base on the computation power of AMD K6-2 233 MHz (ha~ very slow CPU). It can also be use to compare the performance on ARM base devices.

http://www.tux.org/~mayer/linux/bmark.html

The results of my computer. Not that fast
= = =

$ nbench
BYTEmark* Native Mode Benchmark ver. 2 (10/95)
Index-split by Andrew D. Balsa (11/97)
Linux/Unix* port by Uwe F. Mayer (12/96,11/97)

TEST                : Iterations/sec.  : Old Index   : New Index
                    :                  : Pentium 90* : AMD K6/233*
--------------------:------------------:-------------:------------
NUMERIC SORT        :          1323.9  :      33.95  :      11.15
STRING SORT         :          222.57  :      99.45  :      15.39
BITFIELD            :      4.4029e+08  :      75.53  :      15.78
FP EMULATION        :          236.86  :     113.66  :      26.23
FOURIER             :           25906  :      29.46  :      16.55
ASSIGNMENT          :          33.154  :     126.16  :      32.72
IDEA                :            7018  :     107.34  :      31.87
HUFFMAN             :          2775.9  :      76.98  :      24.58
NEURAL NET          :          46.583  :      74.83  :      31.48
LU DECOMPOSITION    :          1589.2  :      82.33  :      59.45
==========================ORIGINAL BYTEMARK RESULTS==========================
INTEGER INDEX       : 84.283
FLOATING-POINT INDEX: 56.617
Baseline (MSDOS*)   : Pentium* 90, 256 KB L2-cache, Watcom* compiler 10.0
==============================LINUX DATA BELOW===============================
CPU                 : Dual AuthenticAMD AMD Athlon(tm) II X2 240e Processor 1600MHz
L2 Cache            : 1024 KB
OS                  : Linux 3.18.6-1-ARCH
C compiler          : gcc version 4.9.2 20150304 (prerelease) (GCC)
libc                :
MEMORY INDEX        : 19.955
INTEGER INDEX       : 21.878
FLOATING-POINT INDEX: 31.402
Baseline (LINUX)    : AMD K6/233*, 512 KB L2-cache, gcc 2.7.2.3, libc-5.4.38
* Trademarks are property of their respective holder.

2015年3月9日 星期一

More on Wifi Network

Super-G
- Super G is Atheros' proprietary frame-bursting, compression, and channel bonding technology to improve IEEE 802.11g (Wi-Fi) wireless LAN performance. The throughput transmission speed limit when using Super G is claimed to be up to 40 Mbit/s-60 Mbit/s at a 108 Mbit/s signaling rate, which is achieved through the bonding of two 54 Mbit/s 802.11g channels.

802.11h
IEEE 802.11h-2003, or just 802.11h, refers to the amendment added to the IEEE 802.11 standard for Spectrum and Transmit Power Management Extensions. It solves problems like interference with satellites and radar using the same 5 GHz frequency band. It was originally designed to address European regulations but is now applicable in many other countries. The standard provides Dynamic Frequency Selection (DFS) and Transmit Power Control (TPC) to the 802.11a PHY. It has been integrated into the full IEEE 802.11-2007 standard.

The above setting appear on my openwrt router. Just enable it for simply