Posts

Showing posts from 2014

Setup environment for python developer in windows :)

Hi my friend :)     Sometime I may have a change to develop something in window, this is a guide to get python development up! Actually I just found powershell, interesting!!! http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/ https://pip.pypa.io/en/latest/installing.html

Try ubuntu 14.04 on my old macbook pro late 2009 (Part2)

Try ubuntu 14.04 on my old macbook pro late 2009 (Part2) I trying to do something to make touchpad feel same as in OSX This is one I can find Section "InputClass"         Identifier "touchpad catchall"         Driver "synaptics"         MatchIsTouchpad "on"         Option "FingerHigh" "10"         Option "FingerLow" "1"         Option "TapAndDragGesture" "off"         Option "PalmDetect" "on" EndSection Section "InputClass"     Identifier         "Touchpad"     Driver             "synaptics"     MatchIsTouchpad    "on"     Option         "ClickFinger3" "2"     Option         "HorizTwoFingerScroll" "1"     Option         "VertScrollDelta" "85"     Option         "HorizScrollDelta" "85"     Option         "TapButton1" "0&q

Try ubuntu 14.04 on my old macbook pro late 2009 (Part1)

Aha, This is what I dream for long time to get Linux on MacBookPro. This is what I have done Start with DVD Ubuntu 14.04 I found a loud noise of fan, so I did     sudo apt-get install lm-sensors fancontrol     sudo pwmconfig (don't know what this command did, but I notice nothing)     sudo sensors-detect (last step, did allow it to auto load) I found that I can't adjust brightness so I did     edit /etc/rc.local         put this             echo '1' > /sys/devices/platform/applesmc.768/leds/smc::kbd_backlight/brightness             echo '5' > /sys/class/backlight/apple_backlight/brightness     for 2 steps above, I'm not sure if they work or not but I did more         sudo nvidia-xconfig ( got invalid xorg.conf )     then I did edit /etc/X11/xorg.conf     In "Device" section, add         Option "RegistryDwords" "EnableBrightnessControl=1"     I did reboot, then it's work like a charm             

Cannot change brightness setting using function button or the brightness

I'm got new machine from new workplace, It's HP Probook. It's look quite good but I have got a problem about changing screen brightness doesn't work. So I google and found this https://askubuntu.com/questions/332657/cannot-change-brightness-setting-using-function-buttons-or-using-the-brightness, This blog put me through that problem. So this is my note sudo vi /etc/default/grub for this var GRUB_CMDLINE_LINUX="", set value "acpi_backlight=vendor" sudo update-grub restart then , yeh, many thanks for https://askubuntu.com/users/183206/aaditya-bagga

9 Awesome Google features we should use [memo]

9 Awesome Google features we should use Google Flight Search usage : "flight from to Google Public Data Explorer usage : "unemployment in the u.s." Google Translate usage : "translate to " Google Nutrition Comparison Search usage : "compare broccolli and asparagus" Google Definition usage : "define " Google Convertion usage : "convert eight ounces to cups" Google nGrams : We can search how many times specific words occur. Google Sky Exclude Search Term usage : "puppies -sales" ; you don't want sites that sales in the result. Reference  and thank to (Kim Komando - www.komando.com)

Using git with my case #1

Using git with my case #1 Display branch >>> git branch -a -v >>> git branch -r ; display remote branches >>> git remote update origin --prune Delete branch >>> git branch -d ; delete local branch >>> git push origin : ; delete remote after delete local branch >>> git push origin --delete ; delete remote Get data from remote ( origin ) >>> git fetch origin ; get info of remote branch to our local machine note*     git pull do         1. git fetch         2. git merge Diff local with remote or others >>> git diff >>> git diff ; diff local branch with remote branch Fetching >> git fetch ; fetch all branches heads >> git fetch --tags ; fetch all tags Start Hotfix 1. Check latest tag     >> git fetch --tags 2. Start hotfix tags     >> git tags ; check latest tags     >> git flow hotfix start

Think of using Xvfb

Xvfb - X Virtual Frame Buffer Xvfb  is an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory. ผมค้นพบโปรแกรมนี้ เนื่องจากความต้องการที่จะทำ UI Test ซึ่งเป็นส่วนประกอบย่อยของระบบ Continuour Integration ที่ผมพัฒนาอยู่ (ตอนที่เขียนบทความนี้ โครงงานที่ทำอยู่หันไปใช้ phantomjs แล้ว :P ) ผมเห็นความเป็นไปได้ในการเอาโปรแกรมนี้ไปใช้ซึ่งมีคนเอาไปทำแล้วอย่างเช่น plugin ที่ใช้ใน jenskin (CI). และแน่นอนผมคาดว่ามันจะสามารถทำงานกับ selenium ทีเวลาที่ตัว selenium ทำงานจะเปิดหน้า webbrowser ขึ้นมา สำหรับงานเทสระบบเว็ป โปรแกรมนี้น่าจะเป็นอะไรที่เข้าทางเลยทีเดียว :) Reference xvfb -> http://www.x.org/archive/X11R7.7/doc/man/man1/Xvfb.1.xhtml buffer - > http://en.wikipedia.org/wiki/Buffer_(computer_science) frame buffer -> http://en.wikipedia.org/wiki/Framebuffer jenskin-xvfb-plugin -> https://wiki.jenkins-ci.org/display/JENKINS/Xvfb+Plugin

Create sequence with zero padding

Hmm I got to pull series of git source from 01-13. But I'm too lazy so I googled then I found program `seq` I don't know it much but it can >>> seq 1 10 1 2 3 4 5 6 7 8 9 10 >>> seq -w 1 10 01 02 03 04 05 06 07 08 09 10 >>> seq -w 01 10 01 02 03 04 05 06 07 08 09 10 Aha, So I see the light!! >> for id in `seq -w 01 13`; do git pull XXXXX$id; done; Yeh,! Many thank to links below!! :) http://stackoverflow.com/questions/6446672/generating-huge-lists-of-numbers http://stackoverflow.com/questions/8789729/zero-padding-in-bash

Using hexdump to check special chars on files

When you suspect on some word that will hide something inside. And I already have compare file. First thing I will try >>> diff file1 file2 Then I know more which word, so I >>> grep file1 And I'm not sure what wrong with it , I will >>> grep file1 | hexdump -C got thing like 00000000  48 65 6c 6c 6f 20 48 6f  77 20 61 72 65 20 79 6f  |Hello How are yo| 00000010  75 20 74 6f 64 61 79 0a  0a                       |u today..| 00000019 But I think it useless, I decide to >>> grep file1 | hexdump -c got this 0000000   H   e   l   l   o       H   o   w       a   r   e       y   o 0000010   u       t   o   d   a   y  \n  \n                             0000019 the default thing is here 0000000 6548 6c6c 206f 6f48 2077 7261 2065 6f79 0000010 2075 6f74 6164 0a79 000a                0000019 That's it. Thank Kirit :)

Change GTK2 Themes to Clear Plastic than oxygen-gtk is make Terminator looks better :)

Currently, I use Kubuntu 13.04. I can't remember when I started found border of Terminator gone. But I found some tip from jippie that suggest to change gtk2 theme to other that oxygen-gtk. Then WOW Its look better, Still borderless but NO space between application's window and viewport ( i try to describe view-region in our display ). Yeh Thank  http://askubuntu.com/questions/377133/does-borderlessmaximizedwindows-false-still-work-with-kubuntu-13-10 *** some info in that link said like So, this feature was added to the oxygen window decoration. Unfortunately, this change didn't make it into the 4.11 release, so we'll have to wait until KDE 4.12 in kubuntu 14.04 (see  bug 324011 ). so I will waiting for it.

Something should keep in mind

'''It's not a problem, just need to be careful when doing this sort of thing. Guessing leads to hard to track down problems because things aren't exactly how they should be''' ... Kirit (20120202)

Mount hfs+ system ( especially mac drive )

Hi pow 1. Let's do >>> sudo apt-get install hfsprogs 2. Unmount that drive, then >>> sudo fsck.hfsplus /dev/sdb2 or sudo fsck.hfsplus -f /dev/sdb2 Above are for checking its health 3. Do mount! >>> sudo mount -t hfsplus -o force,rw /dev/sdb2 /media/ ,just that my friend! :)

How do I switch window in byobu

If you hold alt-key then use left-right arrow key. Then you can move around byobu window

Things to to after install postgresql in linux

After you have done  >> sudo apt-get install postgresql You're open to these things. You have to know that the system must have at least one db that named of you. You need to create that. You can, but it need to do this first Edit pg_hba.conf (locate on /etc/postgresql/ /main/pg_hba.conf Add 2 lines local all all trust host all all 127.0.0.1/32 md5 then restart postgresql service Login to postgresql >> sudo -u postgres psql template1 psql> create user " " with password ' '; psql> alter user " " with superuser; psql>\q >> createdb " " -E UTF8 -O " " That's it. :)

Software Engineering Keywords

ผมเขียนโปรแกรมมาตั้งนานยังไม่ค่อยแน่ใจเรื่องความหมายของคำเหล่านี้เลย edge case bourdary case cornor case base case ถึงเวลาต้องรู้จักมันจิงๆแล้วซักที

โหลดไฟล์ด้วย urllib2

urllib2 module เป็นตัวที่ผมชอบและใช้อยู่เป็นประจำ นี่เป็น code ที่ผมเขียนเก็บไว้เพื่อใช้กับ code อื่นๆในการเขียน script ที่ใช้โหลดไฟล โดยมาจะใช้โหลดเว็ปการตูนต่างๆ import urllib2 def download(filename, img_url):     p = urllib2.urlopen(img_url)     with open(filename, 'w') as f:         f.write(p.read()) จิงๆแล้วบางเว็ปอาจจะห้าม user-agent ที่ไม่รู้จักโหลดไฟล ด้วยความสามารถของ urllib2 เราก็จะทำแบบนี้ได้ import urllib2 def download(filename, img_url):     req = urllib2.Request(img_url, headers={'User-Agent':'Mozilla/5.0'})     p = urllib2.urlopen(req)     with open(filename, 'w') as f:         f.write(p.read()) จะเห็นได้ว่าเราสามารถกำหนด header ได้เองและ img_url ก็แกะออกมาได้จาก beautifulsoup module นั่นเอง หึหึหึ

การใช้งาน beautifulsoup สำหรับ python

ใช้ beautifulsoup ทำอะไรได้     เราสามารถใช้โมดูลตัวนี้แกะ dom เพิ่มหรือลบ element ออกจาก dom ได้ ติดตั้ง beautifulsoup >> pip install beautifulsoup4 ลองเล่นกัน >> from bs4 import Beautifulsoup ผมจะลองโหลดหน้าเว็ปจาก google มาดู >> import urllib2 >> p = urllib2.urlopen('http://google.com') >> soup = Beautifulsoup(p) ลอง print ดู ก็จะได้เห้น content เต็มๆ >> print soup ถ้าทำแบบนี้ >> soup.find_all('table') เราก็จะได้ list ของ table ทั้งหมด ใน page นั้น ตัว soup นี้จะมี fn find_*** เยอะมาก อย่างเช่นถ้าเราทำแบบนี้ >> soup.find_all('table')[0] ผลที่ได้ก็จะเป็น element obj ที่เป็นของ bs นั่นเอง ซึ่งเราสามารถเอา attr ออกมาได้โดย >> t0 = soup.find_all('table')[0] >> print t0.attrs >> {'cellpadding': '0', 'cellspacing': '0'} โดยส่วนตัวผมใช้เจ้า bs (Beautifulsoup) ในการแกะเอา link ต่างเพื่อมาใช้โหลดอีกที เพราะว่าผลที่ออกมาจาก code ด้านบ

Git tips # 2014-01-22

Command Today Use git log to see change by N  entry >> git log -p -N

Byobu + Tmux Tips # 2014-01-22

Scenario#1     As a Byobu-Tmux user, I want to broadcast command to multiple panes. So that I don't have to do the same thing for each pane. solution#1 enter command mode => PREFIX + : active this feature => setw synchronize-panes on deactive => setw synchronize-panes off Scenario#2     As a Byobu-Tmus user, I want to have a shortcut to maximize/minimize current pane. So that I can see/work on specific pane efficiently. solution#1 edit ~/.byobu/keybindings.tmux fill-in these code below # maximum pane and restore unbind + bind + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom  unbind -  bind - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom # resize pane bind H resize-pane -L 1 bind J resize-pane -D 1 bind K resize-pane -U 1 bind L resize-pane -R 1 Scenario#3     As a Byobu-Tmux user, I want to copy/paste