Skip to content

Instantly share code, notes, and snippets.

View k2052's full-sized avatar
🦄
awesome

K k2052

🦄
awesome
View GitHub Profile
@k2052
k2052 / howNotToBuildLoopsInCoffescript.coffee
Created February 12, 2012 20:33
For loops in coffeescript. Be careful how you port your code.
# This will never end because i++ wont be reached more than three times.
i = 0
i = 0
while i <= 10
continue if i is 3
console.log "The number is " + i
console.log "\n"
i++
  • Angers someone = 0.50 (negative or positiving depending on whether or not that person is liked)
  • Long term Physical Health = 0.98
  • Long term Mental Health = 0.95
  • Short term Mental Health = 0.99
  • Short term Physical Health = 0.85
  • Endangers Self = -0.80
  • Causes Someone to develop emotional attachment = -0.95
@k2052
k2052 / addbinary.rb
Created January 20, 2012 22:55
Add two binary strings using ruby.
class Numeric
def ones_complement(bits)
self ^ ((1 << bits) - 1)
end
end
def addbinary(b1, b2)
result = ''
carry = 0
@k2052
k2052 / setup_new_mac_environment.md
Created January 18, 2012 19:34
Setup New Mac Environment

General

  • Disable caps lock key (Sys Pref => Keyboard => Modifier Keys)
  • System Pref -> Security -> Sleep Password

Apps

@k2052
k2052 / gear.md
Created October 3, 2011 00:12
Zombie Apocalypse Survival Guide.

The shit you'll need.

@k2052
k2052 / group_by_date_mongodb.js
Created August 30, 2011 18:36
Group By Date Mongodb
/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
* Licensed under the MIT license.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time) {
var date = time,

History

This all started when I moved to a design-in-browser workflow over the winter.

Designing in the browser is a workflow pain, jumping back into photoshop & shiny up a design is a productivity killer. I try to work in code as long as possible and avoid PS. I originally started out with an HTML/CSS to PSD converter using the PS API, although I got pretty far I quickly discovered it was going to be too slow. Parse HTML and for everything element create relevant layers, PS could barely handle it much less perform effectively.

I had two options; 1. Reverse engineer a PSD format writer or 2. Start work on a app that could speak both graphics and HTML. The latter seemed like an easier task so here I am.

The Basics.

@k2052
k2052 / README.md
Created July 11, 2011 16:23
If God Was A Programmer

The Universe.

Worked on this last week. Not quite complete, very early alpha. Use at your own risk!

Getting started

  1. $ gem source --add http://god.org
  2. $ gem install strings
  3. $ gem install atoms
should "be able to filter based on a symbol or path in a controller" do
mock_app do
controllers :foo do
before(:index, '/foo/main') { @test = 'before'}
get :index do
@test
end
get :main do
@test
end
TestingRoutes.controllers :main do
before(:index) { @test = 'before'}
get :index, :map => '/test' do
@test
end
end