Skip to content

Instantly share code, notes, and snippets.

// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@chrishamant
chrishamant / hookpuller.py
Created May 2, 2011 23:47 — forked from JakeWharton/hookpuller.py
Takes a GitHub service hook POST and automatically updates the associated repo.
#!/usr/bin/env python
'''
Takes a GitHub service hook POST and automatically updates the associated repo.
'''
__license__ = '''
Copyright 2009 Jake Wharton
hookpuller is free software: you can redistribute it and/or modify
@chrishamant
chrishamant / gist:972566
Created May 14, 2011 19:58 — forked from paulirish/gist:366184
html5 geolocation with fallback.
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
;(function(geolocation){
if (geolocation) return;
var cache;
@chrishamant
chrishamant / tomcat.sh
Created November 11, 2011 14:01 — forked from valotas/tomcat.sh
Tomcat init.d script
#!/bin/bash
#
# tomcat7 This shell script takes care of starting and stopping Tomcat
#
# chkconfig: - 80 20
#
### BEGIN INIT INFO
# Provides: tomcat7
# Required-Start: $network $syslog
# Required-Stop: $network $syslog
@chrishamant
chrishamant / boto_mpupload_1
Created January 3, 2012 19:25 — forked from garnaat/boto_mpupload_1
An IPython transcript showing use of S3 MultiPart Upload in boto
In [1]: import boto
In [2]: c = boto.connect_s3()
In [3]: b = c.lookup('test-1245812163')
In [4]: mp = b.initiate_multipart_upload('testmpupload2')
In [5]: mp
Out[5]: <MultiPartUpload testmpupload2>
#!/usr/bin/env ruby1.9.1
#
# Testing multipart uploads into s3
# Very basic script for testing how the functionality works
#
# Takes a file, splits it up
# For each part get the base64 encoded md5 of the part
# Then run through the parts and upload them
# Refs:
@chrishamant
chrishamant / nodejs.sh
Created February 1, 2012 01:17 — forked from crcastle/nodejs.sh
Node.js tartup script for AWS EC2 Linux box
#!/bin/bash
# nodejs - Startup script for node.js server
# chkconfig: 35 85 15
# description: node is an event-based web server.
# processname: node
# server: /path/to/your/node/file.js
# pidfile: /var/run/nodejs.pid
#
@chrishamant
chrishamant / less.less
Created June 15, 2012 21:47 — forked from paulmillr/less.less
Sass vs Stylus vs LESS
.border-radius (@radius) {
-webkit-border-radius: @radius;
-o-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
border-radius: @radius;
}
.user-list {
// need to use special `.` syntax
@chrishamant
chrishamant / pattern-examples.swift
Created October 27, 2015 19:15 — forked from terhechte/pattern-examples.swift
Swift pattern examples for the swift, for, and guard keywords
import Foundation
// 1. Wildcard Pattern
func wildcard(a: String?) -> Bool {
guard case _? = a else { return false }
for case _? in [a] {
return true
}
@chrishamant
chrishamant / dragon.py
Created February 26, 2016 07:13 — forked from fogleman/dragon.py
Dragon Curve with Turtle Graphics (Python)
import turtle
def turn(i):
left = (((i & -i) << 1) & i) != 0
return 'L' if left else 'R'
def curve(iteration):
return ''.join([turn(i + 1) for i in range(2 ** iteration - 1)])
if __name__ == '__main__':