Skip to content

Instantly share code, notes, and snippets.

View ryanhanwu's full-sized avatar
🎯
Focusing

Ryan Wu ryanhanwu

🎯
Focusing
View GitHub Profile
@ryanhanwu
ryanhanwu / ipad.css
Created August 30, 2012 09:00
ipad specific css (responsive)
@media only screen and (device-width: 768px) {
/* For general iPad layouts */
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
/* For portrait layouts only */
}
@media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
/* For landscape layouts only */
@ryanhanwu
ryanhanwu / snippet.js
Created September 12, 2012 11:48 — forked from christopherdebeer/snippet.js
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
@ryanhanwu
ryanhanwu / test.sh
Created September 29, 2012 16:26
Bash Tip
#replace previous command str1 to str 2
^str1^str2^
or
!!:gs/str1/str2/
# execute the most recent command the contains the following string:
!?ncm
@ryanhanwu
ryanhanwu / .gitignore
Created October 2, 2012 07:24
sina weibo OAuth with node-oauth for node.js+express
node_modules
config.js
@ryanhanwu
ryanhanwu / ViewController1.m
Created October 3, 2012 07:03
Nib Way pass value
- (IBAction)passValueButton:(id)sender { //An action method
{
User *user = [[User alloc] init];
user.name = "Ryan";
user.age = "26";
//get the instance of ViewController2
ViewController2 *viewCtrl2 = [[SecondViewController alloc]
initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];
viewCtrl2.user = user;
@ryanhanwu
ryanhanwu / ViewController1.m
Created October 3, 2012 07:12
StoryBoard pass value between viewcontrollers
- (IBAction)passValueButton:(id)sender { //An action method
[self performSegueWithIdentifier:@"gotoView2" sender:self];
}
#pragma mark handle segue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"gotoView2"]) {
User *user = [[User alloc] init];
user.name = "Ryan";
user.age = "26";
@ryanhanwu
ryanhanwu / GeneralData.h
Created October 3, 2012 08:17
Pass value by singleton
+(GeneralData *) sharedInstance;
@property (nonatomic) User *user;
@ryanhanwu
ryanhanwu / numberlock.js
Created October 16, 2012 10:25
number only lock
function(event) {
// Allow: backspace, delete, tab, escape, and enter
if ( event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
// Allow: Ctrl+A
(event.keyCode == 65 && event.ctrlKey === true) ||
// Allow: home, end, left, right
(event.keyCode >= 35 && event.keyCode <= 39)) {
// let it happen, don't do anything
return;
}
@ryanhanwu
ryanhanwu / ota-test.html
Created October 25, 2012 09:01
Auto trigger ios OTA download
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<title>AutoUpdate</title>
<link rel="shortcut icon" href="/imgs/favicon.png" type="image/x-icon">
<link rel="apple-touch-icon" href="http://dl.dropbox.com/u/15540367/Forever/ota-test.png">
</head>
<body>
@ryanhanwu
ryanhanwu / Javascript-base.sublime-snippet
Created November 21, 2012 03:58 — forked from LeZuse/Javascript-base.sublime-snippet
Sublime Javascript snippets
<snippet>
<content><![CDATA[base(this, '${1:method}'${2});${0}]]></content>
<tabTrigger>base</tabTrigger>
<scope>source.js</scope>
<description>Base method call</description>
</snippet>