Skip to content

Instantly share code, notes, and snippets.

View jimmycuadra's full-sized avatar
☠️
GitHub profits from the separation of families and the deaths of children.

jimmycuadra

☠️
GitHub profits from the separation of families and the deaths of children.
View GitHub Profile
@jimmycuadra
jimmycuadra / dontsaythese.textile
Created June 2, 2011 19:56
Shit you are not allowed to say

English

  • boss
  • nippy
  • hubby
  • fisticuffs
  • nighters
  • om nom nom
  • curled up with a glass of wine
  • I’m living life to the fullest
@jimmycuadra
jimmycuadra / call_apply_bind.js
Created June 15, 2011 18:36
Examples of call, apply, and bind
// Our implementation of Function.prototype.bind
Function.prototype.bind = function() {
var __method = this, args = Array.prototype.slice.call(arguments), object = args.shift();
return function() {
var local_args = args.concat(Array.prototype.slice.call(arguments));
if (this !== window) local_args.push(this);
return __method.apply(object, local_args);
}
};
@jimmycuadra
jimmycuadra / jquery-template-example.html
Created June 20, 2011 21:45
jQuery Template example
<!DOCTYPE html>
<html>
<head>
<title>jQuery Template Example</title>
</head>
<body>
<ul id="engineers"></ul>
<script id="tmpl-engineer" type="text/x-jquery-tmpl">
<li>${name}</li>
@jimmycuadra
jimmycuadra / apple-store-map.html
Created August 28, 2011 06:21
Apple Stores in Southern California
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Locations of Apple Stores</title>
<style type="text/css">
html, body {
height: 100%;
margin: 0;

KeyValue

KeyValue is a simple key value store written in Ruby for Codebrawl #9. It provides programmatic and command line access to the store. The data is persisted as JSON, serialized to a file.

Programmatic access:

require "key_value"

kv = KeyValue.new
@jimmycuadra
jimmycuadra / reset.css
Created September 11, 2011 10:45
HTML5 reset CSS with whitespace fixes and alphabetical properties
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, figcaption, figure,
@jimmycuadra
jimmycuadra / wat_do.coffee
Created September 14, 2011 04:39
Syntax question for CoffeeScript
# Given a function that accepts a function followed by a non-function argument...
foo = (callback, name) ->
console.log "Calling callback #{name}..."
callback()
# you end up with a line starting with
# a comma which just feels wrong...
foo ->
console.log "Callback called!"
, "bar"
@jimmycuadra
jimmycuadra / saythese.md
Created December 2, 2011 19:40
Shit you are encouraged to say

English

  • zwerbly
@jimmycuadra
jimmycuadra / gist:1539035
Created December 30, 2011 09:47
Insert Open/Close Tag (With Current Word)
#!/usr/bin/env ruby
#
# This script will expand the current word into: <word></word>
# It will recognize HTML 4.0 tags that need no close tag.
#
# With no current word, it will insert: <p></p> and allows you
# to overwrite the tag name and add potential arguments.
#
# The result is inserted as a snippet, so it's
# possible to tab through the place holders.
@jimmycuadra
jimmycuadra / gist:2026000
Created March 13, 2012 01:19
Daemonize a process with Ruby
def daemonize_app
if RUBY_VERSION < "1.9"
exit if fork
Process.setsid
exit if fork
Dir.chdir "/"
STDIN.reopen "/dev/null"
STDOUT.reopen "/dev/null", "a"
STDERR.reopen "/dev/null", "a"
else