Skip to content

Instantly share code, notes, and snippets.

Michael Chen yuhua-chen

Block or report user

Report or block yuhua-chen

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
@yuhua-chen
yuhua-chen / Drag-and-drop-uitableviewcell-swift2.swift
Created Aug 6, 2015
Demo the drag and drop UITableViewCell in Swift 2.
View Drag-and-drop-uitableviewcell-swift2.swift
struct Drag {
static var placeholderView: UIView!
static var sourceIndexPath: NSIndexPath!
}
func handleLongPress(gesture: UILongPressGestureRecognizer) {
let point = gesture.locationInView(tableView)
let indexPath = tableView.indexPathForRowAtPoint(point)
switch gesture.state {
@yuhua-chen
yuhua-chen / hypenize.js
Last active Jan 10, 2016
Replace special chars with hyphen.
View hypenize.js
function hyphenize(string) {
string = string.replace(/[^A-Za-z0-9\. -]/g, '');
return string.replace(/ */g, '-');
}
var str = "Nike The Future One / Interactive Setting"
hyphenize(str)
// "Nike-The-Future-One-Interactive-Setting"
@yuhua-chen
yuhua-chen / yahoo_bid_category.js
Last active Aug 29, 2015
Yahoo 奇摩拍賣商品分類
View yahoo_bid_category.js
var url = 'https://tw.bid.yahoo.com/tw/0-all.html?.r=1432872568'
var cheerio = require('cheerio')
var https = require('https')
https.get(url, function(response) {
var responseData = ""
response.setEncoding('utf-8')
response.on('data', function(data){
responseData += data
})
@yuhua-chen
yuhua-chen / dump-selectors
Created Aug 4, 2014
Dump all selectors from a class.
View dump-selectors
- (void)dumpAllSelector:(Class) SomeClass
{
id t = [[SomeClass alloc] init];
int i=0;
unsigned int mc = 0;
Method * mlist = class_copyMethodList(object_getClass(t), &mc);
NSLog(@"%d methods", mc);
for(i=0;i<mc;i++)
NSLog(@"Method no #%d: %s", i, sel_getName(method_getName(mlist[i])));
@yuhua-chen
yuhua-chen / config.fish
Created Jul 13, 2014
Showing git branch in fish shell prompt
View config.fish
set fish_git_dirty_color red
set fish_git_not_dirty_color green
function parse_git_branch
set -l branch (git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/\1/')
set -l git_diff (git diff)
if test -n "$git_diff"
echo (set_color $fish_git_dirty_color)$branch(set_color normal)
else
View .screenrc
#screen setting
#cjkwidth off
startup_message off
#support 256 color
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
#statusbar
caption always "%{=u .r} %-w%<%{=ub .Y}%n %t%{=u .r}%+w "
hardstatus alwaysignore
You can’t perform that action at this time.