Skip to content

Instantly share code, notes, and snippets.

View colinhicks's full-sized avatar

Colin Hicks colinhicks

View GitHub Profile
@colinhicks
colinhicks / grunt-typescript.js
Created December 18, 2012 18:38
Grunt task for TypeScript compilation
module.exports = function(grunt) {
'use strict';
// TODO: ditch this when grunt v0.4 is released
grunt.util = grunt.util || grunt.utils;
var async = grunt.util.async;
grunt.registerMultiTask('typescript', 'Compile TypeScript to JavaScript', function() {
var helpers = require('grunt-contrib-lib').init(grunt),
@colinhicks
colinhicks / typescript-gruntfile.js
Created December 18, 2012 18:41
Gruntfile TypeScript config
typescript: {
compile: {
files: {
'temp/scripts/app-all.js': 'app/scripts/**/*.ts'
},
options: {
comments: true,
declarations: false,
exec: false,
module: 'commonjs',
@colinhicks
colinhicks / cdnfallback.js
Last active December 10, 2015 14:29
Basic jQuery CDN fallback
<script src="http://the.cdn.com/path/to/jquery.js"></script>
<script>window.jQuery || document.write('<script src="local/path/to/jquery.js"><\/script>')</script>
@colinhicks
colinhicks / treety-iterator.js
Created January 11, 2013 17:01
musing on projection signature for `treety` – a recursive directory creator
var treetyIterator = function(obj) {
var leaf = {
children: [{
name: 'a1',
children: [{
name: 'b1',
children: [{
name: obj.id,
files: [{
@colinhicks
colinhicks / underscore-skip-take.js
Last active December 11, 2015 03:38
LINQ-influenced skip/take for Underscore
_.mixin({
skipTake: function(array, options) {
options = _.extend({skip:0, take:0}, options || {});
return _(array)
.chain()
.rest(options.skip)
.first(options.take || array.length - options.skip)
@colinhicks
colinhicks / getphotos.casper.js
Created January 15, 2013 14:55
Scrape image urls using casper
var casper = require('casper').create(),
images = [];
// console arguments
var sourcePage = casper.cli.get(0),
filterExpression = casper.cli.get(1);
function getPhotoUrls() {
var els = document.querySelectorAll('img');
@colinhicks
colinhicks / nt.html
Created February 20, 2013 21:40
newsticker consumption
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<ul id="here-is-where-i-want-a-newsticker"></ul>
<!--
@colinhicks
colinhicks / obr.js
Created December 4, 2013 21:56
outbrain.deob.js
window.OB_releaseVer = "131699";
OBR = window.OBR || {};
OBR.i = OBR.i || [];
OBR.na = OBR.na || {};
window.OBR$ = function(d) {
return document.getElementById(d)
};
OBR.c = OBR.c || function() {
var d = {}, a = {
F: function() {
import { Connection } from 'tedious';
class TediousClient {
constructor(config) {
this.config = config;
this._cx = null;
}
connect() {
if (!this._cx) {
(defn then [promise-ch f]
(let [out (async/promise-chan)]
(async/pipeline-async 1 out #(async/pipe (f %1) %2) promise-ch)
out))