This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function selectFrom(table, props) { | |
return 'SELECT ' + joinProperties(props) + ' FROM ' + table + '\n' | |
function joinProperties(props) { | |
return ' '+map(props, function(rawName, prettyName) { | |
return rawName+' as '+prettyName | |
}).join(', ')+' ' | |
} | |
} | |
selectFrom('person p', { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install perl s3 library | |
sudo cpan Net::Amazon::S3 | |
# Grab script | |
curl https://gist.github.com/marcuswestin/4597941/raw/delete-s3-bucket.pl > ./delete-s3-bucket.pl | |
# Run script | |
perl ./delete-s3-bucket.pl --access-key-id=AWS_ACCESS_KEY_ID --secret-access-key=AWS_ACCESS_KEY_SECRET --bucket=BUCKET_NAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# Copyright (c) 2010 Jonathan Kamens. | |
# Released under the GNU General Public License, Version 3. | |
# See <http://www.gnu.org/licenses/>. | |
# $Id: delete-s3-bucket.pl,v 1.5 2010/10/26 14:11:09 jik Exp $ | |
# Deleting an Amazon S3 bucket is hard. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) blur:(UIWebView*)webView { | |
[self findAndResignFirstResponder:webView]; | |
} | |
- (bool) findAndResignFirstResponder:(UIView*)view { | |
if ([view isFirstResponder]) { | |
[view resignFirstResponder]; | |
return YES; | |
} | |
for (UIView* subview in [view subviews]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) hideKeyboard { | |
UITextView* view = [[UITextView alloc] initWithFrame:CGRectMake(0,0,0,0)]; | |
[webView addSubview:view]; | |
[view becomeFirstResponder]; | |
[view resignFirstResponder]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)keyboardWillShow:(NSNotification *)notification { | |
[self performSelector:@selector(removeWebViewKeyboardBar) withObject:nil afterDelay:0]; | |
} | |
- (void)removeWebViewKeyboardBar { | |
UIWindow *keyboardWindow = nil; | |
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) { | |
if (![[testWindow class] isEqual:[UIWindow class]]) { | |
keyboardWindow = testWindow; | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function has(obj, props) { | |
each(props, function(propsVal, key) { | |
var objVal = obj[key] | |
if (propsVal == null) { return objVal === propsVal } | |
else if (isArray(propsVal) || typeof propsVal == 'object') { has(objVal, propsVal) } | |
else { | |
if (objVal != propsVal) { throw new Error('has: '+objVal+' != '+propsVal) } | |
} | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
// Setup & Run | |
describe:describe, | |
then:then, | |
run:run, | |
// Assertion utils | |
is:is, | |
// DOM utils | |
tap:tap, | |
waitFor:waitFor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isTouch | |
try { document.createEvent("TouchEvent"); isTouch = ('ontouchstart' in window) } | |
catch (e) { isTouch = false } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html><head> | |
<style> | |
.light { position:absolute; border-radius:5px; background:black; } | |
.light.on { background:yellow; } | |
</style> | |
</head><body> | |
<div id="lights"></div> | |
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> |