This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import urllib | |
import urllib2 | |
def safe_add(x, y): | |
lsw=(x&0xFFFF)+(y&0xFFFF) | |
msw=(x>>16)+(y>>16)+(lsw>>16) | |
return lshift(msw, 16)|(lsw&0xFFFF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#caution!! for file name with spaces may fail | |
for f in *.png *.jpg | |
do | |
size=`convert $f -ping -format "%wx%h" info:` | |
echo $size >> tmp | |
mkdir -p "$size" && cp $f "$size" | |
done | |
cat tmp | sort -u > index.log | |
echo "category done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cover=`date --iso-8601=seconds | cut -d'+' -f1`.jpg | |
function getCover { | |
### get jpeg file from bing home page | |
url="http://cn.bing.com" | |
echo "Find header image..." | |
wget -q $url -O index.html | |
# jpgUrl=`cat index.html | grep background-image | awk -F\' '{print $2}'` | |
jpgUrl=`cat index.html | tr ";" "\n" | grep -o "url:'http://.*[.]jpg"| cut -d\' -f2` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
s1=`du -b $1|cut -f1` | |
s2=`du -b $2|cut -f1` | |
min=$(($s1 < $s2 ? $s1 : $s2 )) | |
if [ $min -eq $s1 ]; then | |
dd if=$2 of=temp bs=$min count=1 >& /dev/null | |
echo $1 is smaller and its md5sum is: | |
echo $(md5sum $1) | |
echo cut $2 to $1\'s size and its md5sum is: | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "readparam.h" | |
char* delblank( char* str ) | |
{ | |
char* out = str; | |
int i, j; | |
for( i = 0, j = 0; i < strlen( str ); i++,j++ ) | |
{ | |
if( str[i] == ' ' || str[i] == '\n') | |
{ |