去掉某个字段的一个字符
2013年7月26日 16:34
去掉over_under_handicap字段的第一个“大”
update asia_odds set over_under_handicap = SUBSTRING(over_under_handicap, LOCATE('大' ,over_under_handicap)+1);
INSTALLING HADOOP ON MAC OSX LION
2013年6月18日 18:25
今天按照这个教程,把hadoop装上了,先挖个坑,记下来,后边再调格式好了。
原文链接
Quick Summary
1.Install Hadoop
2.Edit Configuration
A.Edit hadoop-env.sh to handle SCDyanmicStore related errors
B.Edit core-site.xml
C.Edit mapread-site.xml
D.Edit hdfs-site.xml
3.Enable ssh to localhost
4.Start and Test Hadoop
Top 10 Unix Command Line Utilities
2013年6月18日 17:37
原文链接
0> tr
tmp > echo "adbdc" | tr "abc" "123" 1d2d3
tmp > echo "Hello" | tr "A-Za-z" "a-zA-Z" hELLO
tmp > echo $PATH | tr ":" "\n" | sort /Users/oliver/.cabal/bin /Users/oliver/.rvm/bin /Users/oliver/.rvm/gems/ruby-1.9.3-p0/bin /Users/oliver/.rvm/gems/ruby-1.9.3-p0@global/bin /Users/oliver/.rvm/rubies/ruby-1.9.3-p0/bin /Users/oliver/local/node/bin /Volumes/macbox_cs/dev/android-sdk-macosx/platform-tools/ ...
1> sort
tmp > du /bin/* | sort -n -r | head -4 1320 /bin/ksh 1264 /bin/sh 1264 /bin/bash 592 /bin/zsh
sort
will take multiple files as input and will merge and sort all of the files for you. Some of the most used options include -r
for sorting in reverse order and -f
for sorting case-insensitive.
2> uniq
Want to get rid of duplicate lines? uniq
solves this problem efficiently. Note that it will only compare adjacent lines for equality, so you might want to sort before you use uniq
.
Nice options: -c
will prepend the count of equal elements before a line, -u
will only output lines that are not repeated and -i
does the whole thing case-insensitive.
Here is an example that combines tr
, sort
and uniq
such that you can get the frequency of all words in a wikipedia article:
tmp > curl http://en.wikipedia.org/wiki/Minimum_spanning_tree \ | tr -cs "A-Za-z" "\n" | tr "A-Z" "a-z" \ | sort | uniq -c | sort -n -r % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 93342 100 93342 0 0 279k 0 --:--:-- --:--:-- --:--:-- 323k 1031 a 568 span 442 href 435 class 308 li 300 b 284 title 229 wiki 211 the 209 cite 206 id 192 spanning 184 i 169 tree 166 minimum ...
判断手机有没有被root
2013年5月31日 16:53
原文链接
http://code.google.com/p/roottools/
if (RootTools.isRootAvailable()) { // your app has been granted root access } if (RootTools.isAccessGiven()) { // your app has been granted root access }
whenever执行时一直报错
2013年5月29日 21:35
在rails项目中使用使用whenever时,一直报各种找不到命令,如:zsh: command not found: Gemfile,等等等。。。。。。
查了好多资料,一直没解决,今天在unbuntu上新建了一个空项目能正常使用,于是把笔记本上的项目拷到ubuntu上,还是报错,/usr/bin/env :ruby.exe 找不到指令或文件,最开始没注意到,后来一看,ubuntu上怎么会用到exe?于是网上又查找,把项目中/script/rails文件中的#!/usr/bin/env ruby.exe修改成#!/usr/bin/env ruby,果然好了。原来的项目是在windows下生成的,所以才会有这种问题。真尼玛。
Mac上的项目执行whenever还是报错env: ruby: No such file or directory,不过手动执行脚本可以运行。
于是把/script/rails中的#!/usr/bin/env ruby 改成了 #!/Users/username/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
Mac上也可以运行了。
这段时间记录的一些杂七杂八的笔记
2013年5月28日 17:06
ruby代码
1.upto 10 do |i| puts i if i==3..i==5 end
sql代码
--方法1 慢。。。。。 select postby,(select count(*) from articles where status=1 and postby=ar.postby) as art_num,(select count(*) from articles where status=1 and isgood=1 and postby=ar.postby) as goodart_num,title from articles as ar group by postby order by goodart_num desc,art_num desc limit 10 --方法2 快。。。。。 select postby,sum(case when status=1 then 1 else 0 end) as art_num,sum(case when status=1 and isgood=1 then 1 else 0 end) as goodart_num,title from articles group by postby order by goodart_num desc,art_num desc limit 10;
What's the difference between .bashrc, .bash_profile
2013年5月28日 10:26
/bin/bash The bash executable /etc/profile The systemwide initialization file, executed for login shells ~/.bash_profile The personal initialization file, executed for login shells ~/.bashrc The individual per-interactive-shell startup file ~/.bash_logout The individual login shell cleanup file, executed when a login shell exits ~/.inputrc Individual readline initialization file