Skip to content

Instantly share code, notes, and snippets.

View skw's full-sized avatar

Shaun Wong skw

  • GitHub Staff
  • Calgary, AB
View GitHub Profile
@skw
skw / tree.coffee
Last active December 15, 2015 06:39
node.js coffeescript function that returns json tree representation of directory structure
fs = require 'fs' # node file system module
path = require 'path' # node path module
# returns json tree representation of directory structure
tree = (root) ->
# clean trailing '/'
root = root.replace /\/+$/ , ""
# extract tree ring if root exists
if fs.existsSync root
ring = fs.lstatSync root
@skw
skw / app.html
Last active December 16, 2015 01:39 — forked from ded/app.html
Updated Ender/script.js async js asset loading example.
<script src="ender.min.js"></script>
<script>
$script('/js/core.min.js', 'core')
$script.ready('core', function () {
$(document).ready(function () {
$('<p>hello world</p>').appendTo('body')
.bind('click', function (e) {
$script('/js/ajax.min.js', function () {
@skw
skw / gist:5622844
Last active December 17, 2015 14:09 — forked from berzniz/gist:2900905
CS Fork get handle bar template function example
# get template on the fly
Handlebars.getTemplate = (name)->
if Handlebars.templates is undefined or Handlebars.templates[name] is undefined
$.ajax(
url: "/templates/" + name
success: (data) ->
Handlebars.templates = {} if Handlebars.templates is undefined
Handlebars.templates[name] = Handlebars.compile(data)
error: (xhr, options, err) ->
console.log xhr.status
@skw
skw / less2stylus.coffee
Last active December 17, 2015 19:19 — forked from lancejpollard/less2stylus.coffee
made some changes to make it work for me
# Quick hack of regular expressions to convert twitter bootstrap from LESS to Stylus
fs = require 'fs'
less2stylus = (string) ->
string = string
.replace(/^(\ *)(.+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/^(\ *)([^\ \n]+)\ +\{\ *\n?\ */mg, "$1$2\n$1 ") # remove opening brackets
.replace(/\ *\{\ *\n*/g, "\n") # remove opening brackets again (some random cases I'm too lazy to think through)
.replace(/\ *\}\ *\n*/g, "\n") # remove closing brackets
@skw
skw / normalize.stylus
Last active December 17, 2015 23:08
normalize.stylus v2.1.2
//
// Box-sizing mixin
//
box-sizing($boxmodel)
-webkit-box-sizing $boxmodel
-moz-box-sizing $boxmodel
box-sizing $boxmodel
/*! normalize.stylus, stylus port of normalize.css v2.1.2 | MIT License | git.io/normalize */
@skw
skw / the_future_of_rustboy.md
Last active September 16, 2018 07:28
The Future of Rustboy - For archival purposes.

Transcribed for archival purposes.

Excerpts from "The Future of Rustboy"

an interview with Brian Taylor - by Steve Ogden - Nov 2011

OGDEN:

Did Rustboy fall victim to Hollywood’s notorious “Development Hell”, or to “One-Man Show Fatigue Syndrome”? (Or a combination?)

@skw
skw / gitm
Created June 19, 2013 21:07
shell scripts
git commit -am "$*" && git push origin master
/*jshint node:true*/
'use strict';
var path = require('path'),
url = require('url'),
when = require('when'),
ffs = require('final-fs');
var reworkRecompile = function (cssPath, reworkPath, doRework) {
return ffs.readFile(reworkPath, {encoding: 'utf-8'})
@skw
skw / package.json
Created October 17, 2013 20:30
example mocha with custom args
{
"name": "test"
, "version": "0.0.1"
, "description": "mocha"
, "keywords": ["test", "tutorial"]
, "author": "skw"
, "main": "index"
, "engines": { "node": "*" }
, "scripts": {
"test": "make test"
@skw
skw / video.js
Created October 23, 2013 18:22 — forked from seanhagen/video.js
describe( "Video model", function(){
var MOCK_GET_DATA = {
channelName: "tgndeveloperedu",
commentCount: 0,
defaultOrder: 0,
dislikeCount: 0,
facebookCount: "0",
googleCount: "0",
likeCount: 0,