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
class MyDict(dict): | |
def get(self, key): | |
return self.get_key_or_attr(key) | |
def __getitem__(self, key): | |
return self.get_key_or_attr(key) | |
def get_key_or_attr(self, key): | |
if self.has_key(key): | |
return dict.__getitem__(self, key) |
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
def iterate_in_steps(seq, n, increment): | |
if len(seq) >= n: | |
return [tuple(seq[:n])] + iterate_in_steps(seq[increment:], n, increment) | |
else: | |
return [] | |
# >>> iterate_in_steps([1, 2, 3, 4, 5], 2, 1) | |
# [(1, 2), (2, 3), (3, 4), (4, 5)] | |
# | |
# >>> iterate_in_steps([1, 2, 3, 4, 5], 3, 2) |
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
// | |
// UILabel+withString.h | |
// | |
#import <Foundation/Foundation.h> | |
@interface UILabel (withString) | |
+ (UILabel *)labelWithString:(NSString *)string | |
font:(UIFont *)font |
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
; Depends on [com.notnoop.apns/apns "0.1.6"]. | |
(:import ('com.notnoop.apns APNS)) | |
(defn send-push-notification [device-token message] | |
(let [service (.build (.withSandboxDestination | |
(.withCert (APNS/newService) "resources/apns-dev-cert.p12" "password"))) | |
payload (.build (.alertBody (APNS/newPayload) message))] | |
(.push service device-token payload))) |
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
// | |
// UITextField+withFrame.h | |
// | |
#import <Foundation/Foundation.h> | |
@interface UITextField (withFrame) | |
+ (UITextField *)textFieldWithFrame:(CGRect)frame |
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 mongo = require('mongodb'), | |
mongoStore = require('connect-mongodb'); | |
var mongo_config = { | |
host: "staff.mongohq.com", | |
port: 10004, | |
dbname: "appXXX", | |
username: "username", | |
password: "password"}; |
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/env python2 | |
# http://bgp.he.net/AS32934#_prefixes | |
import os | |
netblocks = [ | |
"31.13.24.0/21", | |
"66.220.144.0/21", | |
"66.220.152.0/21", | |
"69.63.176.0/21", |
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
.veneer_overlay { | |
position: absolute; | |
top: 0%; | |
left: 0%; | |
width: 100%; | |
height: 100%; | |
background-color: black; | |
z-index: 1001; | |
-moz-opacity: 0.5; | |
opacity: 0.5; |
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 fun = (function() { | |
var self = {}; | |
self.element = (function() { | |
var self = {}; | |
self.events = (function() { | |
// Based on http://dean.edwards.name/my/events.js. | |
var self = {}; |