Skip to content

Instantly share code, notes, and snippets.

var worstFunctionEver = function (badArg) {
while (1) {
if (badArg == "hello") {
console.log("worst code ever");
}
}
}
@chuckha
chuckha / blastoff.swift
Created August 19, 2014 03:42
Straight up breaks the playground
func test() -> String {
func innerTest(n: Int) -> String {
if n == 0 {
return "Blast off"
}
return innerTest(n - 1)
}
return innerTest(10)
}
@chuckha
chuckha / yas.swift
Created August 20, 2014 04:24
yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas
func yas(numOfAs: Int) -> String {
var ret = "y"
for i in 1...numOfAs {
ret += "a"
}
return ret + "s"
}
yas(10)
package db
import (
"fmt"
"github.com/eaigner/jet"
_ "github.com/lib/pq"
)
var (
Db *jet.Db
var addTwo = function(x, y) {
if (typeof(x) != "number" || typeof(y) != "number") {
//log it and bail
}
};
@chuckha
chuckha / lightsout_example.js
Created February 18, 2012 01:26
javascript string and integer addition/concatenation
// The first three are strings, the last is a number
"1" + "2" = "12";
"1" + 2 = "12";
1 + "2" = "12";
1 + 2 = 3;
// These are all numbers
"1" - 2 = -1;
"1" - "2" = -1;
1 - "2" = -1;
@chuckha
chuckha / license_generator.vim
Created April 3, 2012 19:18
License Generator for SBO projects
function! LicenseGenerator()
let date = strftime("%c")
call search("# encoding: utf-8")
return "# Created by Chuck Ha on " . date . "\n# Copyright (c) 2012 Safari Books Online, LLC. All rights reserved.\n\n"
endfun
nmap <silent> ,li "=LicenseGenerator()<CR>p
@chuckha
chuckha / license_generator.vim
Created April 4, 2012 13:15 — forked from meirish/license_generator.vim
License Generator for SBO projects
function! LicenseGenerator()
let date = strftime("%c")
if &ft == "javascript"
return "/*jslint bitwise: true, browser: true, eqeqeq: true, immed: true, newcap: true, regexp: true, nomen: false, onevar: false, undef: true, plusplus: false, white: true, indent: 2 */\n/*global confirm define interpolate gettext console */\n\n// Created by Matthew Irish (mirish@safaribooksonline.com) on " . date . "\n/*! Copyright (c) 2012 Safari Books Online, LLC. All rights reserved.*/\n\n"
endif
if &ft == "python"
return "# encoding: utf-8\n\n# Created by Chuck Ha (chuck@safaribooksonline.com) on" . date . "\n# Copyright (c) 2012 Safari Books Online, LLC. All rights reserved.\n\n"
endif
endfun
@chuckha
chuckha / base.rb
Created August 15, 2012 14:19
base role for safarilabs
name "base"
description "A base role for all safarilab nodes"
run_list(
# Add recipes or roles here
"recipe[build_essential]"
)
@chuckha
chuckha / fizzbuzz.erl
Created September 21, 2012 14:07
Erlang fizzbuzz
-module(fizzbuzz).
-export([fizzbuzz/1]).
-define(MOD_THREE, "fizz").
-define(MOD_FIVE, "buzz").
% Helper function to map fizzbuzz across a sequence of numbers
fizzbuzz(To) ->
lists:map(fun nt/1, lists:seq(1, To)).