Skip to content

Instantly share code, notes, and snippets.

View liuyix's full-sized avatar

Yi Liu liuyix

  • Shanghai
  • 17:19 (UTC +08:00)
View GitHub Profile
@liuyix
liuyix / android_whole_contacts_phones.java
Created June 3, 2012 14:38
getting whole phone numbers and names of contacts in android | [Chinese] 获得所有联系人名字和号码
Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
while (phones.moveToNext())
{
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
phones.close();
@liuyix
liuyix / .gitconfig
Created July 26, 2012 14:08
Github via goagent
[http]
proxy = http://127.0.0.1:8087
sslVerify = false #注意一定要添加这一行用以解决“ SSL certificate problem: unable to get local issuer certificate”
[https]
proxy = http://127.0.0.1:8087
@liuyix
liuyix / floorLog2.c
Created January 14, 2013 12:20
simple log 2 calculation implement (from pintool demo)
int32_t FloorLog2(uint32_t n)
{
int32_t p = 0;
if (n == 0) return -1;
if (n & 0xffff0000) { p += 16; n >>= 16; }
if (n & 0x0000ff00) { p += 8; n >>= 8; }
if (n & 0x000000f0) { p += 4; n >>= 4; }
if (n & 0x0000000c) { p += 2; n >>= 2; }
cout <<"edit distance for t1 & t2:";
long long total_it_ed = 0;
for( i = 0; i < it_ed.size(); i++)
{
cout << it_ed[i] << "," ;
total_it_ed += it_ed[i];
}
cout << endl;
cout <<"edit distance for c1 & c2:";
@liuyix
liuyix / linux-life-guide.markdown
Last active December 15, 2015 15:19
Linux日常使用指南

压缩/解压缩

git http代理(校园网免流量)

校园网免国际流量代理

office

中文输入法问题

@liuyix
liuyix / xrange.py
Created April 3, 2013 03:01
self define python range
def xrange(start,end,step):
'''
range [start,end)
'''
r = start
while r < end:
yield r
r += step
@liuyix
liuyix / 0.python_tips_index.md
Last active December 15, 2015 17:59
Python学习备忘

#Python Tips

调用外部命令

detect function type

read large file

@liuyix
liuyix / file_exists.sh
Created May 6, 2013 03:12
Check if a file exists with wildcard in shell script link:http://stackoverflow.com/a/6364244
if ls /path/to/your/files* &> /dev/null; then
echo "files do exist"
else
echo "files do not exist"
fi
@liuyix
liuyix / macro.md
Created May 7, 2013 02:08
C/C++ Macro string concatenation

If they're both strings you can just do:

#define STR3 STR1 STR2

The preprocessor automatically concatenates adjacent strings.

@liuyix
liuyix / recover.sh
Created May 12, 2013 05:08
Recover grub after installing windows in grub shell
# first manual boot into ubuntu
root (hd0,X)
kernel /boot/vmlinuz... root=/dev/sdaX
initrd /boot/initrd...
boot