Skip to content

Instantly share code, notes, and snippets.

@yonglam
yonglam / AttachedObject.h
Created April 10, 2019 12:33
AttachedObject
@interface NSObject (BDWRuntime)
- (void)bdw_attachObject:(id)obj forKey:(NSString *)key;
- (id)bdw_getAttachedObjectForKey:(NSString *)key;
- (void)bdw_attachObject:(id)obj forKey:(NSString *)key isWeak:(BOOL)bWeak;
- (id)bdw_getAttachedObjectForKey:(NSString *)key isWeak:(BOOL)bWeak;
@end
@yonglam
yonglam / gif.m
Created February 11, 2019 02:38
生成GIF
- (void)makeAnimatedGif:(NSArray *)images filePath:(NSString *)filePath ration:(CGFloat)ration
{
NSInteger count = images.count;
CGImageDestinationRef destination;
CFURLRef url = CFURLCreateWithFileSystemPath(
kCFAllocatorDefault,
(__bridge CFStringRef)filePath,
kCFURLPOSIXPathStyle,
@yonglam
yonglam / TZReceptionist.h
Created February 2, 2019 11:59 — forked from pala/TZReceptionist.h
Receptionist Pattern
#import <Foundation/Foundation.h>
typedef void (^RCTaskBlock)(NSString *keyPath, id object, NSDictionary *change);
@interface TZReceptionist : NSObject
+ (id)receptionistForKeyPath:(NSString *)path
object:(id)obj
queue:(NSOperationQueue *)queue
task:(RCTaskBlock)task;
@end
'''
phone number regex
-------------------'''
def isPhoneNumber(text):
if len(text) != 12:
return False #not phone number-sized
for i in range(0, 3):
if not text[i].isdecimal():
return False
set hlsearch
set incsearch
set ignorecase
set smartcase
set scrolloff=3
imap jj <Esc>
" Window operation
nnoremap <Space>ww <C-W>w
@yonglam
yonglam / git_log
Last active March 2, 2016 07:30
git log
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset - %C(yellow)%d%Creset %C(blue)%s%Creset %C(dim cyan)<%an>%Creset %C(dim white)(%ci)%Creset' --abbrev-commit"
@yonglam
yonglam / safe_git_ci
Created February 4, 2016 09:43
Check some restrictive condition before ci to local git
#!/bin/sh
# Check test code
v=$(git diff | grep -i -e '^\+.*paul' -e '^\+.*//.*@test' -e '^\+.*/\*.*@test')
if [ "x$v" != "x" ]
then
echo "\033[31m Commit Failed! *** Reason: Test codes are added! *** \033[0m"
echo "$v"
exit
fi
@yonglam
yonglam / safe_svn_ci
Last active March 1, 2016 11:18
Check some restrictive condition befor commit to svn server
#!/bin/sh
# Check test code
v=$(svn diff | grep -i -e '^\+.*paul' -e '^\+.*//.*@test' -e '^\+.*/\*.*@test' -e '^\+.*DevelopmentTeam\s*=\s*')
if [ "x$v" != "x" ]
then
echo "\033[31m Commit Failed! *** Reason: Test codes are added! *** \033[0m"
echo "$v"
exit
fi
@yonglam
yonglam / package_ipa
Created February 4, 2016 09:31
Package a ipa file
on open of listFile set srcFile to the first item of listFile set myFolderName to "Payload" set wechatFileName to "wechat.ipa" tell application "Finder" if not (exists folder myFolderName of desktop) then set wechatItem to make new folder at desktop with properties {name:myFolderName} end if duplicate srcFile to folder myFolderName of desktop with replacing --set itemPath to POSIX path of (folder "Wechat" of desktop as alias) --set thePath to POSIX path of (desktop as alias) & "Wechat.zip" --do shell script "zip -r " & quoted form of thePath & " " & quoted form of itemPath do shell script "cd ~/desktop && zip -r " & wechatFileName & " " & myFolderName delay 1 delete folder myFolderName delay 1 beep tell application "Google Chrome" activate set theUrl to "http://rdm.wsd.com/sign.jsp" if (count every window) = 0 then make new window end if set found to false set theTabIndex to -1 repeat with theWindow in every window set theTabIndex to 0
@yonglam
yonglam / zshrc
Last active March 2, 2016 07:30
zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases