Skip to content

Instantly share code, notes, and snippets.

View asyncanup's full-sized avatar

Anup Bishnoi asyncanup

View GitHub Profile
@remy
remy / long-lived.js
Created September 17, 2014 20:46
Sample node server that sends chunked script tags.
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, { 'content-type': 'text/html' });
res.write('<script>console.log("this is the start of the stream...")</script>');
var timer = setInterval(function () {
if (!res.connection || !res.connection.writable) {
try { res.end(); } catch (e) {}
clearInterval(timer);
@jashkenas
jashkenas / npm-publish-semver.coffee
Last active August 18, 2016 21:10
A little script to publish a "semantic" version of any npm package that uses real version numbers.
#!/usr/bin/env coffee
fs = require 'fs'
sh = require 'execSync'
config = JSON.parse fs.readFileSync 'package.json'
fs.renameSync 'package.json', 'package.json.real'
name = config.name = "#{config.name}-semver"
@remy
remy / html-slides-to-pdf.js
Created June 13, 2014 21:38
Converts HTML slides (usually via reveal) to a PDF - useful for video editing
/*global console:true, phantom:true, slidedeck:true*/
var webpage = require('webpage'),
page = webpage.create(),
system = require('system'),
url = system.args[1] || 'index.html',
fs = require('fs'),
imageSources = [],
imageTags,
width = system.args[2] || 1920,
/*
Swift Programming Language Guide
"A Swift Tour" Solutions
https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2-XID_1
These are the solutions to all the "experiments" in the pre-release Swift Programming Guide
(released on the same day Apple announced Swift). A couple of things worth noting:
1. Swift syntax, e.g. array declarations, has changed since I releasd these. So this code will
probably cause some errors when you paste it into a playground. Should be easy enough to fix
@airportyh
airportyh / jsconf_slides_codes_and_notes.md
Last active June 19, 2017 20:51
JSConf 2014 Slides, Codes and Notes.

JSConf Slides, Codes and Notes

These are all the JSConf 2014 slides, codes, and notes I was able to cull together from twitter. Thanks to the speakers who posted them and thanks to @chantastic for posting his wonderful notes.

Modular frontend with NPM - Jake Verbaten (@Raynos)

@jchris
jchris / examples.js
Created September 23, 2012 14:49
pretend code: launch the app, connects to couchbase, also some examples
var couchbase = require("couchbase"),
config = {
hosts : ["localhost:8091", "localhost:9000"],
bucket : "TapLibz",
password : "buzz-the-tower",
};
// would be neat to have default connection level
// options (place to set observe and expiration, etc)
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@TooTallNate
TooTallNate / cocoa-hello-world2.js
Created September 8, 2011 17:07
Creating a Cocoa GUI window with NodObjC, with a proper Menu, dock icon, and NSApplicationDelegate.
// This example adapted from Matt Gallagher's "Minimalist Cocoa Programming"
// blog article:
// http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
var $ = require('NodObjC')
$.import('Cocoa')
var pool = $.NSAutoreleasePool('alloc')('init')
, app = $.NSApplication('sharedApplication')
@creationix
creationix / module.js
Created April 19, 2011 04:27
A super simple module system for browsers. Assumes all source files are concatenated and in browser.
define.defs = {};
define.modules = {};
function define(name, fn) {
define.defs[name] = fn;
}
function require(name) {
if (define.modules.hasOwnProperty(name)) return define.modules[name];
if (define.defs.hasOwnProperty(name)) {
var fn = define.defs[name];
define.defs[name] = function () { throw new Error("Circular Dependency"); };