Skip to content

Instantly share code, notes, and snippets.

@snowleung
snowleung / halfpng
Created October 16, 2012 18:49
iphone @2x.png to png
#coding=utf8
import Image
import math
import os
import re
import glob
class image:
watermarkfile_default = '~/warter.png'
def __init__(self,watermark=''):
@snowleung
snowleung / gist:4286512
Created December 14, 2012 16:04
decelerationRate
CGFloat decelerationRate = UIScrollViewDecelerationRateFast +(UIScrollViewDecelerationRateNormal - UIScrollViewDecelerationRateFast) * INT16_MAX;
[_tableView setValue:[NSValue valueWithCGSize:CGSizeMake(decelerationRate,decelerationRate)] forKey:@"_decelerationFactor"];
//发送通知
UILocalNotification *notification=[[UILocalNotification alloc] init];
if (notification!=nil) {
NSDate *now=[NSDate new];
notification.fireDate=[now dateByAddingTimeInterval:10];//10秒后通知
notification.repeatInterval=0;//循环次数,kCFCalendarUnitWeekday一周一次
notification.timeZone=[NSTimeZone defaultTimeZone];
notification.applicationIconBadgeNumber=1; //应用的红色数字
notification.soundName= UILocalNotificationDefaultSoundName;//声音,可以换成alarm.soundName = @"myMusic.caf"
//去掉下面2行就不会弹出提示框
@snowleung
snowleung / terminal
Created December 18, 2012 07:45
mac os NTFS readonly
sudo mount -u -w /Volumes/ntfs_volume_name
@snowleung
snowleung / hidefile.sh
Created January 12, 2013 02:20
hide the empty file with git
#!/bin/sh
FILE_NAME='empty'
if [ $1 ! = ''] && [$1 = '-f' ] && [$2 != ''];then
FILE_NAME = $2
else
echo '====================================================='
echo 'cleana.sh -f filename '
echo ' set the file name,if not,default name is '$FILE_NAME
echo '====================================================='
fi
@snowleung
snowleung / ck2x.sh
Created January 12, 2013 10:07
check the 2x file
#!/bin/sh
#check 2x file
FILE_PAR='*@2x.*'
file_res=$(find . -name "$FILE_PAR")
#echo $file_res
for f in $file_res
do
@snowleung
snowleung / deprecated_file.sh
Created February 21, 2013 08:13
use sed to deprecate ios class and method
#!/bin/bash
flist=`find . -name "*.h"`
#echo $flist
for f in $flist
do
echo $f
`sed -i "" '/@interface.*/{s/@interface/__attribute__ ((deprecated))\'$'\n@interface/g;}' $f`
`sed -i "" "/-.*;/{s/;/ __attribute__ ((deprecated));/g;}" $f`
@snowleung
snowleung / solution
Created April 10, 2013 05:49
bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8)
sudo apt-get install language-pack-en-base
edit:
/etc/environment
append this:
LANGUAGE="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
@snowleung
snowleung / swap_keybroad
Created August 3, 2013 06:00
swap caps lock and left ctrl ,work for windows xp 3rd
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00
@snowleung
snowleung / revert_keybroad
Created August 3, 2013 06:01
revert caps lock and left ctrl
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex: