Skip to content

Instantly share code, notes, and snippets.

kyon kyon0304

Block or report user

Report or block kyon0304

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kyon0304
kyon0304 / readparam.c
Created Aug 4, 2014
read config file use c
View readparam.c
#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')
{
@kyon0304
kyon0304 / chunkCmp.sh
Created Jul 7, 2014
最近总是在作的重复性工作,比较两个二进制文件的内容是否一致。。Orz
View chunkCmp.sh
#!/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
@kyon0304
kyon0304 / newFille.sh
Last active May 6, 2018
auto generate YAML front-matter for jekyll post, scrape a background image from bing and normalize it for post's header
View newFille.sh
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`
@kyon0304
kyon0304 / gradientTransparent.sh
Created Jan 27, 2014
Recursively go through directory and make *.png *.jpg file gradient transparent(half to bottom). ImageMagick needed.
View gradientTransparent.sh
#!/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"
View login_network.py
#!/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)
You can’t perform that action at this time.