Skip to content

Instantly share code, notes, and snippets.

View ktusznio's full-sized avatar
🥙
might be eating a pita

Kamil Tusznio ktusznio

🥙
might be eating a pita
View GitHub Profile
@ktusznio
ktusznio / gist:935156
Created April 21, 2011 18:16
Script to hash up the intl_users csv
def make_hash
f = File.new("/tmp/intl_users_with_name_and_email")
out = open("/tmp/intl_users_json", "w")
proxy_emails = 0
blank_names = 0
total = 0
while (line = f.gets)
begin
@ktusznio
ktusznio / jquery-namespace.js
Created June 22, 2011 22:43
A simple jQuery namespacing function
/**
* Introducing the $.namespace function! It takes a string and gives you a
* global representing the namespace you want.
*
* For example, $.namespace("Causes.Earn.Dialog") => {Earn: {Dialog: {}}}
*
* This gets rid of crufty code like:
*
* if (!Causes) { Causes = {}; }
* if (!Causes.Earn) { Causes.Earn = {}; }
@ktusznio
ktusznio / html
Created August 28, 2011 01:26 — forked from raila/html
batman keypath test
# Create our application and namespace.
class Alfred extends Batman.App
@global yes
# setup our root route. When the app starts up, it will automatically call TodosController::index
@root 'todos#index'
# Define the principal Todo model with `body` and `isDone` attributes, and tell it to persist itself using Local Storage.
class Alfred.Todo extends Batman.Model
@ktusznio
ktusznio / gist:1249409
Created September 28, 2011 22:17
Simple Batman App
<!DOCTYPE html>
<html>
<head>
<title>Test App</title>
<script type="text/javascript" src="../lib/es5-shim.js"></script>
<script type="text/javascript" src="../lib/batman.js"></script>
<script type="text/javascript" src="../lib/batman.solo.js"></script>
<script type="text/javascript" src="../lib/coffee-script.js"></script>
</head>
<body>
@ktusznio
ktusznio / gist:1334781
Created November 2, 2011 20:23
Batman Associations Sample
<!DOCTYPE html>
<html>
<head>
<title>Alfred: Batman's Todos</title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="resources/alfred.css" type="text/css">
<script type="text/javascript" src="../lib/es5-shim.js"></script>
@ktusznio
ktusznio / controller.coffee
Created January 10, 2012 21:24
Batman Filtering
class Shopify.OrdersController extends Shopify.ApplicationController
index: (params) ->
@allOrders = Shopify.Order.get('all')
@_filterOrders()
addFilter: (type, value) ->
@set "#{type}Filter", value
@_filterOrders()
_filterOrders: ->
@ktusznio
ktusznio / gist:1790846
Created February 10, 2012 16:53
batman.js checkbox example
<!DOCTYPE html>
<html>
<head>
<title>Test App</title>
<script type="text/javascript" src="../lib/es5-shim.js"></script>
<script type="text/javascript" src="../lib/batman.js"></script>
<script type="text/javascript" src="../lib/batman.solo.js"></script>
<script type="text/javascript" src="../lib/extras/batman.rails.js"></script>
<script type="text/javascript" src="../lib/coffee-script.js"></script>
</head>
@ktusznio
ktusznio / NSManagedObject+KTManagedObject.h
Created July 16, 2012 18:26
Core Data Categories to get started with Core Data
//
// NSManagedObject+KTManagedObject.h
// Created by Kamil Tusznio on 12-07-10.
//
#import <CoreData/CoreData.h>
@interface NSManagedObject (KTManagedObject)
+ (NSArray *)fetchAll;
@ktusznio
ktusznio / dollarize.coffee
Created October 26, 2012 08:08
Dollarize helper in Coffeescript
dollarize = (n, currency = "$", decimals = 2,
decimalSeparator = ".", thousandsSeparator = ",") ->
if n instanceof String
n = parseInt n, 10
sign = if n < 0 then "-" else ""
wholeDigits = "" + Math.abs(n - (n % 1))
@ktusznio
ktusznio / state_options.haml
Created November 13, 2012 21:43
HAML state options
%select
%option(value="AL") Alabama
%option(value="AK") Alaska
%option(value="AZ") Arizona
%option(value="AR") Arkansas
%option(value="CA") California
%option(value="CO") Colorado
%option(value="CT") Connecticut
%option(value="DE") Delaware
%option(value="FL") Florida