Skip to content

Instantly share code, notes, and snippets.

@tiltedlistener
tiltedlistener / gist:72c6e37eff212c4f5f69
Created July 2, 2014 19:50
Couple Second Ruby Server
require 'webrick'
include WEBrick
server = HTTPServer.new(:Port=>8000,:DocumentRoot=>Dir::pwd ) # Or whatever port you like.
trap("INT"){ server.shutdown }
server.start
# Based off this blog post: http://matteomelani.wordpress.com/2011/11/11/a-simple-web-server-is-ruby/
@tiltedlistener
tiltedlistener / gist:3c7cfbfdd649e3313bb5
Created July 2, 2014 17:14
PHP script used to localize URLs in files to build servers from local
<?php
// Arguments
// File location
// Desired server location
$path_to_file = $argv[1];
$file_contents = file_get_contents($path_to_file);
$file_contents = str_replace('localhost:8888', $argv[2], $file_contents); // Typically hard code this, but code be provided as an argument as well.
file_put_contents($path_to_file,$file_contents);
@tiltedlistener
tiltedlistener / gist:8126eb787b0504c5c1a0
Created July 3, 2014 23:15
Trying to remember format for CoffeeScript object looping
for groupKey, groupValue of WordList
console.log groupValue
doctype html
html(lang="en")
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
title Site Name
meta(name="description", content="")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(name="mobileoptimized", content="0")
link(href='misc/page.min.css', rel='stylesheet')
@tiltedlistener
tiltedlistener / gist:81d2d8b3c85753682eff
Created July 16, 2014 06:09
Dealing with coder error in Swift
init(coder aDecoder: NSCoder!)
{
super.init(coder: aDecoder)
}
@tiltedlistener
tiltedlistener / gist:279431807565618407f8
Created July 30, 2014 20:28
Basic cURL for PHP to hit a webhook
$ch = curl_init("HTTP://SOMEURL.com");
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_TIMEOUT_MS, 10000);
curl_exec( $ch );
$response = curl_getinfo($ch);
curl_close ($ch);
echo $response["http_code"];
@tiltedlistener
tiltedlistener / gist:72c8d61fd199ca83921f
Created August 5, 2014 06:44
Center a JFrame within a screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
@tiltedlistener
tiltedlistener / gist:5c692625eb508397c402
Created August 5, 2014 05:49
BASH to remove all .DS_Stores
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
# http://stackoverflow.com/questions/107701/how-can-i-remove-ds-store-files-from-a-git-repository
[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm";
git branch -D <name-of-branch>
git branch -D -r origin/<name-of-branch>
git push origin :<name-of-branch>'
# http://stackoverflow.com/questions/2003505/how-to-delete-a-git-branch-both-locally-and-remotely