Skip to content

Instantly share code, notes, and snippets.

View iamjwc's full-sized avatar

Justin Camerer iamjwc

  • LimeWire, LLC
  • New York City
View GitHub Profile
#!/usr/bin/env bash
IP=`ifconfig | grep "inet " | grep -v "inet 127.0.0.1" | cut -f 2 -d " "`
PORT=$1
if [ -z "$1" ]
then
PORT=8000
fi
# Copy ip and port to pasteboard
<div style="overflow:hidden; height: 100px">
<span id="1" style="height:50px;" />
<span id="2" style="height:50px;" />
<span id="3" style="height:50px;" />
</div>
# From: http://www.quirksmode.org/js/cookies.html
window.CookieHelpers =
expiry: (days) ->
date = new Date
date.setTime(date.getTime()+(days*24*60*60*1000))
"; expires=#{date.toGMTString()}"
write: (name, value, days) ->
expires = if days then this.expiry(days) else ""
document.cookie = "#{name}=#{value}#{expires}; path=/"
class Parent
def self.print_name
puts self.name
end
def self.name
"Parent"
end
end
@iamjwc
iamjwc / file.json
Last active October 13, 2015 05:17 — forked from anonymous/file.json
{"songs": [
{
"globalId": "gold-rush",
"name": "Gold Rush",
"written-by": "Bill Monroe",
"key": "a",
"chord-progression": [
{"section-name": "A", "chords": [
{"key-as-letter": "a", "key-as-roman": "I", "duration": 3.0},
{"key-as-letter": "e", "key-as-roman": "V", "duration": 0.5}
class ThingRepresentation < Representable::Decorator
include Representable::JSON
property :field
end
# This works great.
ThingRepresentation.new(Thing.new).to_json # => { "field": "thing value" }
# This does not work.
190988
190755
190706
191474
191480
191479
191477
167433
61434
196577
@iamjwc
iamjwc / mysql.rb
Last active January 2, 2016 10:19
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.6/en/'
url 'http://downloads.mysql.com/archives/mysql-5.6/mysql-5.6.10.tar.gz'
version '5.6.10'
sha1 'f37979eafc241a0ebeac9548cb3f4113074271b7'
bottle do
sha1 'e07b9a207364b6e020fc96f49116b58d33d0eb78' => :mountain_lion
<script type="text/javascript">
// Make the back button work on the search page.
$(function() {
var addPushState = function() {
// When a link in the pager is clicked, add the new url
// to the pushState to make the back button work.
$('.pager li a').click(function() {
history.pushState({}, '', $(this).attr('href'));
return true;
});
var margin = {top: 1, right: 1, bottom: 6, left: 1},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var formatNumber = d3.format(",.0f"),
format = function(d) { return formatNumber(d) + " TWh"; },
color = d3.scale.category20();