Skip to content

Instantly share code, notes, and snippets.

//
// Automatically calls all functions in APP.init
//
jQuery(document).ready(function() {
APP.go();
});
//
// Module pattern:
// http://yuiblog.com/blog/2007/06/12/module-pattern/
// TinyMCE Settings.
tinyMCE.init({
extended_valid_elements: 'style',
mode: 'exact',
elements: 'id_name',
theme: 'advanced',
theme_advanced_toolbar_location: 'top',
theme_advanced_toolbar_align: 'left',
plugins: 'safari, style, table, paste, media',
theme_advanced_buttons1: 'bold, italic, underline, justifyleft, justifycenter, justifyright, justifyfull, formatselect, fontselect, fontsizeselect',
/* inline-block */
#selector {
display: inline-block;
zoom: 1;
*display: inline;
}
/* min-width */
#selector {
min-width: 80px;
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// answer
(foo)
? bar.doSomething(el)
@banderson
banderson / mathHelpers.java
Created February 6, 2012 16:03
Math Helpers: Greatest Common Divisor & Least Common Multiple
public class MathHelper {
// Find the Greatest Common Divisor using Euclid's Algorithm
// Adapted from: http://en.wikipedia.org/wiki/Greatest_common_divisor#Using_Euclid.27s_algorithm
public static int GreatestCommonDivisor(int a, int b) {
// base case: when b is zero, we've found the GCD
if (b == 0) {
return a;
}
@banderson
banderson / flipper
Last active December 20, 2015 11:39
Ruby Script to flip text
!/usr/bin/env ruby
# encoding: UTF-8
# adapted from http://www.leancrew.com/all-this/2009/05/im-feelin-upside-down/
class Flipper
CHARS = " abcdefghijklmnopqrstuvwxyz,.?!'()[]{}".split('')
FLIPPED_CHARS = " ɐqɔpǝɟƃɥıɾʞlɯuodbɹsʇnʌʍxʎz'˙¿¡,)(][}{".split('')
DICTIONARY = Hash[CHARS.zip FLIPPED_CHARS]
@banderson
banderson / pascal-original.coffee
Last active August 29, 2015 13:56
Pascal's Triangle in Coffeescript
module.exports = (rows) ->
result = []
for n in [0..rows]
if n is 0
result[n] = [1]
else
previous = new Array().concat 0, result[n-1], 0
current = []
for val, idx in previous
sum = val + previous[idx+1]
@banderson
banderson / memoize.js
Created May 30, 2014 22:38
Memoizer: takes in any javascript function and adds memoization based on args
var memoize = function memoize(fn) {
var self = this;
return function newFn() {
newFn.__memo || (newFn.__memo = {});
var args = Array.prototype.slice.call(arguments),
hash = JSON.stringify(args);
return (hash in newFn.__memo)
? newFn.__memo[hash]
@banderson
banderson / template.html
Last active August 29, 2015 14:10
Block Model Test Template
<!DOCTYPE HTML>
<html format=implicit>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="stylesheet" type="text/css" href="https://static.ctctcdn.com/galileo/images/templates/Galileo-Template-Images/GalileoExternalCSS.css">
<style>
table {
@banderson
banderson / github-project-cards.graphql
Created February 8, 2017 05:47
Fetch github project cards via graphql
{
repository(owner: "banderson", name: "life") {
projects(first: 30) {
totalCount
edges {
node {
name
number
url
columns(first: 30) {