Skip to content

Instantly share code, notes, and snippets.

@STRd6
STRd6 / mu.sh
Last active August 29, 2015 13:58
Mush templates into JST
#! /bin/bash
cd templates
for file in *.haml; do
hamlet < $file -r "Hamlet" > ${file/.haml}.js
done
for file in *.js; do
echo "(window.JST || (window.JST = {}))['${file/.js}'] = " > tmpfile
@STRd6
STRd6 / lollable.js
Created May 16, 2014 04:43
Lollable
var Callable, c,
__slice = [].slice;
Callable = function(invoke) {
var fn;
fn = function() {
var _ref;
return (_ref = fn.invoke).call.apply(_ref, [this].concat(__slice.call(arguments)));
};
fn.invoke = invoke;
Observable.concat = (args...) ->
args = Observable(args)
o = Observable ->
flatten args.map(splat)
o.push = args.push
return o
Tab = (name, content) ->
name: name
content: content
tabs = [1..3].map (i) ->
Tab "Tab#{i}", "Hello from tab #{i}"
model =
tabs: tabs
activeTab: Observable tabs[0]
@STRd6
STRd6 / recursive-selection.md
Last active October 18, 2019 19:47
Weird Ideas

Recursive Selection

What would a recursive selection tool look like in a pixel editor?

One should be able to draw fractals using it.

@STRd6
STRd6 / implementation.md
Last active August 29, 2015 14:02
Hamlet Implementation

Hamlet Implementation

There are many existing frameworks and libraries in JavaScript that handle data-binding and application abstractions but none of them offer an integrated solution that works with hihger level languages (CoffeeScript, Haml). You could come close with CoffeeScript + hamlc + Knockout or something similar but it would always be a bit of a kludge because they were never designed to work together.

There are three major issues that should be solved in clientside JavaScript applications:

  1. Improved Language (CoffeeScript, or Dart, TypeScript, etc.)
  2. HTML Domain Specific Language (Haml, Jade, Slim, others)
  3. Data-Binding (React, Knockout, others)
@STRd6
STRd6 / integration.coffee
Last active August 29, 2015 14:03
Using integration to solve greatest contiguous sum problem
integrate = (array) ->
total = 0
array.map (n) ->
total += n
zeros = (array) ->
array.reduce (zeros, n, i) ->
if !(array[i-1] > 0) and n > 0
zeros.push i
@STRd6
STRd6 / spec.md
Last active June 14, 2017 23:07
Jadelet Spec

Hamlet Spec

Tags

Tags map directly to the DOM tag with that name. If the tag is omitted it is assumed to be a div.

h1
#!/bin/bash
set -e
cd component && git pull && cd ..
VERSION=`echo "console.log(require('./package').version)" | node`
script/update_version $VERSION
script/prepublish && script/test && script/standalone
@STRd6
STRd6 / .bash_prompt
Created October 2, 2014 17:51
.bash_prompt
YELLOW="\[\033[0;33m\]"
GRAY="\[\033[0;34m\]"
RESET="\033[0;00m"
if [ -z "$COMP_SYM" ]; then
COMP_SYM="♥"
fi
PS1="\n\! \[\`if [[ \$? = "0" ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi\`\]:\w$YELLOW"'`__git_ps1`'"$GRAY \@$RESET\n$COMP_SYM "