Skip to content

Instantly share code, notes, and snippets.

View guange2015's full-sized avatar

gg guange2015

  • usa
View GitHub Profile
@guange2015
guange2015 / gist:4222185
Created December 6, 2012 06:20
UITapGestureRecognizer响应顺序是怎么样的
一个scrollview上有几个按钮
在scrollview上add 了一个单击事件
singletap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[singletap setNumberOfTapsRequired:1];
[scrollview addGestureRecognizer:singletap];
这样点击按钮,不会响应按钮的事件,直接跳到handleSingleTap去了?
单击事件不是应该先被直接单击的subview处理,如果没有处理才提交到supview处理嘛?
@guange2015
guange2015 / gist:4216457
Created December 5, 2012 15:18
mongo.js
var dburl = 'localhost/mongoapp';
var collections = ['users'];
var db = require('mongojs').connect(dburl,collections);
db.users.save({
name: 'hello',
email: 'hello@world.com'
});
db.users.find({},function (err, users) {
@guange2015
guange2015 / proxy.rb
Created October 22, 2012 09:21 — forked from druzn3k/proxy.rb
A quick HTTP proxy server in Ruby.
#!/usr/bin/env ruby
# A quick and dirty implementation of an HTTP proxy server in Ruby
# because I did not want to install anything.
#
# Copyright (C) 2009 Torsten Becker <torsten.becker@gmail.com>
require 'socket'
require 'uri'
@guange2015
guange2015 / gist:3909604
Created October 18, 2012 02:50
zip-plist-reader
require 'zip/zip'
require 'plist4r'
Zip::ZipFile.open('/tmp/weipass.ipa',Zip::ZipFile::CREATE) { |zipfile|
plist_string = zipfile.read("Payload/MicroPass.app/Info.plist")
p = Plist4r::Plist.new({ :from_string => plist_string })
puts p["CFBundleDisplayName"]
}
@guange2015
guange2015 / _rvmruby.sh
Created September 16, 2012 06:11
_rvmruby
#!/bin/sh
# usage: _rvmruby <ruby version> [ruby arguments]
if [[ -s ~/.rvm/scripts/rvm ]]; then
. ~/.rvm/scripts/rvm
fi
ruby_version=$1; shift
rvm $ruby_version
exec ruby "$@"
@guange2015
guange2015 / lauch.xml
Created September 16, 2012 06:10
plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.ruby-china.rnotice</string>
<key>ProgramArguments</key>
<array>
<string>这里写_rvmruby路径</string>
<string>这里写rvm的gemset ,如1.9.3@temp</string>
@guange2015
guange2015 / compile_vim.sh
Created September 16, 2012 05:55
complie vim
./configure --with-features=huge --disable-largefile \
--enable-perlinterp --enable-pythoninterp \
--enable-rubyinterp --enable-gui=gtk2 \
@guange2015
guange2015 / uitextfield-transparent-view.m
Created September 16, 2012 05:47
uitextfield transparent view
@interface UIClickView : UIView
@property (nonatomic,assign)UITextField* edit;
@end
@implementation UIClickView
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
CGPoint p = [self convertPoint:point toView:self.edit];
if (p.x>0 && p.y>0) {
return nil;
}
return [super hitTest:point withEvent:event];
@guange2015
guange2015 / textfiled_add_transparent.m
Created September 16, 2012 05:45
textfiled add transparent
- (void)textFieldDidBeginEditing:(UITextField *)textField {
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
UIView *mainV = [self getMainView];
clickV = [[UIClickView alloc]initWithFrame:mainV.bounds];
clickV.edit = input;
[mainV addSubview:clickV];
[clickV release];
[self becomeFirstResponder];
}
@guange2015
guange2015 / keyboard.m
Created September 16, 2012 05:40
uitextfield keyboardshow
-(void) keyboardWillShow:(NSNotification*)notification {
NSDictionary* info =[notification userInfo];
kbSize =[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size;
UIView *mainV = [self getMainView];
CGPoint p =[self convertPoint:CGPointMake(0, self.frame.size.height) toView:mainV];
if (p.y + kbSize.height > mainV.frame.size.height) {
[UIView beginAnimations:@"" context:nil];
[UIView setAnimationCurve:0.3];
CGRect rc = mainV.frame;