Skip to content

Instantly share code, notes, and snippets.

function supaTest(){
var tests = [{'name':1},{'name':2}];
var delay = 2000;
for (var i=0; i < tests.length; i++) {
setTimeout( function (test) {
return function () {
console.log(new Date());
console.log(test.name)
}
curvePath = [];
var step = 1 / 100;
var point1, point2, point3;
point1 = {'x': 0, 'y':0};
point2 = {'x':250, 'y':200};
#!/bin/bash
declare -A hosts
hosts[site1]=200
hosts[site2]=201
default=${hosts[site1]}
if [ $1 ]
then
var FeedCat = function () {
this.cat = 'Garfield';
this.feed = function (scope_) {
var scope = scope_;
var feedIt = function (food) {
scope.doFeed(food);
}
@seansullivan
seansullivan / gist:3244870
Created August 3, 2012 05:50
Set up navigation inside view controller
// Note-- @interface ContainingViewController : UIViewController <UINavigationControllerDelegate, UITabBarControllerDelegate>
-(void) setUpNav {
// create tab bar controller and array to hold the view controllers
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController.view setFrame:CGRectMake(0, 0, 300, 100)];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:1];
UIViewController *view1 = [[UIViewController alloc] init];
@seansullivan
seansullivan / gist:4507044
Last active December 10, 2015 23:08
Cross Domain Headers for CompoundJS
#CORS middleware
allowCrossDomain = (req, res, next) ->
res.header 'Access-Control-Allow-Origin', '*'
res.header 'Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'
res.header 'Access-Control-Allow-Headers', 'Content-Type, X-Requested-With'
next()
# Cut off OPTIONS requests and just send true as response
handleOptionsMethod = (req, res, next) ->
return res.send(200) if req.method == 'OPTIONS'
server {
listen 80;
server_name myblog.com;
root /var/www/wp-blog;
## This should be in your http block and if it is, it's not needed here.
index index.html index.php;
location = /favicon.ico {
@seansullivan
seansullivan / s3-deploy
Created August 26, 2013 19:26
Deploy local folder to s3 bucket using s3cmd.
#!/bin/bash
s3cmd sync --delete-removed ./mybucket-local/ s3://mybucket.com
s3cmd setacl --acl-public --recursive s3://mybucket.com
@seansullivan
seansullivan / call_command.py
Created September 9, 2013 18:25
Python call_command for calling command line in script.
def call_command(command):
process = subprocess.Popen(command.split(' '),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
return process.communicate()
# Ex usage: call_command("sudo mount {dev} {mnt}".format(dev=device_path, mnt=mount_path))
@seansullivan
seansullivan / chrome_to_md.sh
Last active December 28, 2015 21:39
Shell script for creating Markdown file from currently active tab and highlighted text in Google Chrome. Intent is to power a Jekyll <http://jekyllrb.com/> blog to replace my old Posterous site. Forked from Jekyll Bookmarklet <http://jonathanbuys.com/04-05-2011/Jekyll_Bookmarklet.html>
#!/bin/bash
TITLE=`osascript -e 'tell application "Google Chrome" \
to return title of active tab of front window'`
URL=`osascript -e 'tell application "Google Chrome" \
to return URL of active tab of front window'`
TEXT=`osascript -e 'tell application "Google Chrome" \
to execute the active tab of front window \