References :
2014年10月29日 星期三
2014年10月27日 星期一
IE Javascript Array.indexOf() error
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(elt, from) {
var len = this.length >>> 0;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
if (from < 0) from += len;
for (; from < len; from++) {
if (from in this && this[from] === elt) return from;
}
return - 1;
};
}
References :
[JS] IE 的 JS 陣列不可使用 indexOf() - 楓葉筆記本- 點部落
javascript function argument default value
function func(a,b){
if(typeof(a)==='undefined') a = 10;
if(typeof(b)==='undefined') b = 20;
alert("A: "+a+"\nB: "+b);
}
//testing
func();
func(80);
func(100,200);
References :
default argument values in javascript functions - Stack Overflow
2014年10月26日 星期日
ImportError: No module named flask.ext.wtf.Required
old :
from flask.ext.wtf import Required
new :
from wtforms.validators import Required
References :
python - I'm not able to import Flask-WTF TextField and BooleanField - Stack Overflow
No module named flask.ext.wtf.TextField
Flask-WTF==0.8.3
Flask-WTF==0.10.2
References :
python - Importing flask.ext.wtf - Stack Overflow
from flask.ext.wtf import TextField
Flask-WTF==0.10.2
from wtforms import TextField
References :
python - Importing flask.ext.wtf - Stack Overflow
grep pattern from a string
$ grep -q xxxx <<< $str
$ echo $?
References :
bash - shell script grep to grep a string - Stack Overflow
2014年10月25日 星期六
No outputs have backlight property
$ xbacklight -dec 10
No outputs have backlight property
try the option on boot :
acpi_backlight=vendor
or
video.use_native_backlight=1
References :
https://bbs.archlinux.org/viewtopic.php?id=177616
https://wiki.manjaro.org/index.php?title=Optimized_power_settings
debian install chinese fonts
# apt-get install fonts-arphic-ukai fonts-arphic-uming fonts-ipafont-mincho fonts-ipafont-gothic fonts-unfonts-core
References :
Help:Multilingual support (East Asian) - Wikipedia, the free encyclopedia
shell script callback function
myfunc() {
str=$1
echo $str
}
callback_handler="myfunc"
if [ "$callbak_handler" != "" ]; then
eval $file_handler asdfghjkl
fi
References :
Friends don't let friends program in shell script | TurnKey GNU/Linux Blog
2014年10月24日 星期五
shell script handle signal
my_signal_handler() {
echo '....'
}
trap 'my_signal_handler' EXIT HUP TERM INT
References :
Work the Shell - Dealing with Signals | Linux Journal
shell script kill subprocess when exit
jobs=() trap '((${#jobs[@]} == 0)) || kill ${jobs[*]} ; exit' EXIT HUP TERM INT subscript1 & jobs+=($!) subscript2 & jobs+=($!)
References :
zsh - Killing subprocesses after the script has finished or is killed - Unix & Linux Stack Exchange
append value to bash array
ARR=()
ARR+=(1)
ARR+=(2)
References :
Bash: add value to array without specifying a key - Stack Overflow
inotifywait background job pid
jobs=()
(echo "$BASHPID" > pid-file; exec inotifywait -m ...) | while IFS= read -r...
jobs+=(`pid-file`)
git delete remote branch
$ git push origin --delete
References :
github - How to delete a Git branch both locally and remotely? - Stack Overflow
2014年10月23日 星期四
vim auto open file in new tab
if (&diff==0)
autocmd VimEnter * tab all
endif
References :
Alternative tab navigation - Vim Tips Wiki
autocmd VimEnter * tab all
endif
References :
Alternative tab navigation - Vim Tips Wiki
2014年10月22日 星期三
irssi hide join part messages
/ignore #channel_name JOINS PARTS QUITS
/save
忽略所有系統訊息:
/ignore #channel CRAP NOTICES SNOTES CTCPS JOINS PARTS QUITS KICKS MODES WALLOPS NICKS DCC DCCMSGS CLIENTNOTICES CLIENTCRAP CLIENTERRORS HILIGHTS
套用至多個 channel:
/ignore -channels #roomA,#roomB,#etc * JOINS PARTS QUITS NICKS
References :
Hide join part messages - XKCD Wiki
LoCoDays/JoiningIn - Ubuntu Wiki
Irssi hacks | fossline
允許 systemd 將 acpi 事件轉交給其他程式處理
# vi /etc/systemd/logind.conf
# 讓 systemd 不處理 acpi 事件# vi /etc/rc.local
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
# 允許 acpi 事件轉交給其他程式處理
PowerKeyIgnoreInhibited=no
SuspendKeyIgnoreInhibited=no
HibernateKeyIgnoreInhibited=no
LidSwitchIgnoreInhibited=no
exec systemd-inhibit acpid
# reboot
References :
Arch Linux:使用systemd管理系統與服務 | 二三事
混乱的笔记本电源管理 (页 1) / 笔记本及其他便携设备 / Arch Linux 中文论坛
Bugs: lilyterm - The data got from socket seems incorrect
The data got from socket seems incorrect
The format of socket data is out of date
temporary solution
References :
不能开多个lilyterm · Issue #55 · Tetralet/LilyTerm
The format of socket data is out of date
temporary solution
$ lilyterm -s
References :
不能开多个lilyterm · Issue #55 · Tetralet/LilyTerm
2014年10月21日 星期二
Mounting a hard disk image with partitions
$ file mydebian.img
mydebian.img: DOS/MBR boot sector
$ fdisk -l mydebian.img
Disk mydebian.img.141022: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00094e94
Device Boot Start End Blocks Id System
mydebian.img.p1 2048 81790975 40894464 83 Linux
mydebian.img.p2 81793022 83884031 1045505 5 Extended
mydebian.img.p5 81793024 83884031 1045504 82 Linux swap / Solaris
$ mount -o loop,offset=$((2048 * 512)) mydebian.img /mnt
References :
Mounting a hard disk image including partitions using Linux | andremiller.net
Loop-mounting partitions from a disk image
2014年10月18日 星期六
X lock screen
xscreensaver :
install
- run in normal user
install
# apt-get install xscreensaverrun xscreensaver
$ vi .xinitrc
$ xscreensaver -nosplash &
lock screen
References :
lock screen in wmii (Page 1) / Applications & Desktop Environments / Arch Linux Forums
DWM auto lock after inactivity (Page 1) / Applications & Desktop Environments / Arch Linux Forums
$ xscreensaver-command -lock
slock :
minimal screen locker
type your password directly
# apt-get install suckless-tools
$ slock
References :
lock screen in wmii (Page 1) / Applications & Desktop Environments / Arch Linux Forums
DWM auto lock after inactivity (Page 1) / Applications & Desktop Environments / Arch Linux Forums
run X11 GUI application in docker
SSH with X11 forwardingVNC- share X11 socket
$ docker run -ti --rm -e DISPLAY=$DISPLAY.0 -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/root/.Xauthority --net=host myimage xterm
add alias to .bashrc
$ alias dockerx11run='docker run -ti --rm -e DISPLAY=$DISPLAY.0 -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/.Xauthority:/root/.Xauthority --net=host '
$ dockerx11run myimage xterm
References :
Running GUI apps with Docker – Fábio Rehm
GoLang hex IP to string
package main
import (
"fmt"
"encoding/hex"
)
func main(){
a, _ := hex.DecodeString("0101A8C0")
fmt.Printf("%v.%v.%v.%v", a[3], a[2], a[1], a[0])
}
References :
convert hex ip addres to net.IP - Google Groups
GoLang string to int
package main
import (
"fmt"
"strconv"
)
func main() {
output, _ := strconv.Atoi("1234")
fmt.Println(output)
}
References :
data - How do I use the strconv.Atoi() method in Go? - Stack Overflow
2014年10月17日 星期五
iwlwifi-6000g2a-5.ucode
Package: firmware-iwlwifi (0.36+wheezy.1) [non-free]
* Intel Wireless 100 firmware, version 39.31.5.1 (iwlwifi-100-5.ucode) * Intel Wireless 105 firmware, version 18.168.6.1 (iwlwifi-105-6.ucode) * Intel Wireless 135 firmware, version 18.168.6.1 (iwlwifi-135-6.ucode) * Intel Wireless 1000 firmware, version 39.31.5.1 (iwlwifi-1000-5.ucode) * Intel Wireless 2200 firmware, version 18.168.6.1 (iwlwifi-2000-6.ucode) * Intel Wireless 2230 firmware, version 18.168.6.1 (iwlwifi-2030-6.ucode) * Intel Wireless 3945 firmware, version 15.32.2.9 (iwlwifi-3945-2.ucode) * Intel Wireless 4965 firmware, version 228.61.2.24 (iwlwifi-4965-2.ucode) * Intel Wireless 5100, 5300 and 5350 firmware, version 8.24.2.12 (iwlwifi-5000-2.ucode) * Intel Wireless 5100, 5300 and 5350 firmware, version 8.83.5.1 (iwlwifi-5000-5.ucode) * Intel Wireless 5150 firmware, version 8.24.2.2 (iwlwifi-5150-2.ucode) * Intel Wireless 6000 firmware, version 9.221.4.1 (iwlwifi-6000-4.ucode) * Intel Wireless 6005 firmware, version 17.168.5.3 (iwlwifi-6000g2a-5.ucode) * Intel Wireless 6030 firmware, version 18.168.6.1 (iwlwifi-6000g2b-6.ucode) * Intel Wireless 6250 firmware, version 9.201.4.1 (iwlwifi-6050-4.ucode) * Intel Wireless 6250 firmware, version 41.28.5.1 (iwlwifi-6050-5.ucode)
References :
Debian -- Details of package firmware-iwlwifi in wheezy
2014年10月16日 星期四
run 32-bit programs on a 64-bit Debian/Ubuntu
# dpkg --add-architecture i386 # enable multi-arch
# apt-get update
# apt-get install libc6:i386 # install base 32bit libraries
References :
apt - Unable to install ia32-libs in Debian Wheezy - Unix & Linux Stack Exchange
Multiarch/HOWTO - Debian Wiki
tar exclude directory
# tar cvf /backup/0000.tar / --exclude 'tmp/*' --exclude 'proc/*'
References :
tar --exclude=directory
2014年10月14日 星期二
Job Queue / Task Queue / Message Queue
Gearman :
Job Queue
Client <-> Gearman <-> Worker
Synchronize, Asynchronous->->
ZeroMQ :
Message Queue and Socket Programming
Celery :
write in Python
no client and worker
queuing task and do task in background
Celery + RabbitMQ for "data" queue in Instragram
Celery doing task and queuing data in RabbitMQ
Queues
Gearman and ZeroMQ, two different animals
https://speakerdeck.com/coudenysj/gearman-and-zeromq-two-different-animals
2014年10月13日 星期一
git show remote repo
$ git remote show
origin
test
$ git config --get remote.origin.url
$ git config --get remote.test.url
execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile
Gemfile
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
# apt-get install nodejs
References :
ruby on rails - execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile - Stack Overflow
2014年10月11日 星期六
2014年10月6日 星期一
訂閱:
文章 (Atom)