Skip to content

Instantly share code, notes, and snippets.

View refset's full-sized avatar
🌍

Jeremy Taylor refset

🌍
View GitHub Profile
@ryanflorence
ryanflorence / static_server.js
Last active July 21, 2024 12:43
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@eriwen
eriwen / cors.js
Created May 26, 2012 15:54
Simple cross-domain Javascript function
/**
* Make a X-Domain request to url and callback.
*
* @param url {String}
* @param method {String} HTTP verb ('GET', 'POST', 'DELETE', etc.)
* @param data {String} request body
* @param callback {Function} to callback on completion
* @param errback {Function} to callback on error
*/
function xdr(url, method, data, callback, errback) {
@MicahElliott
MicahElliott / clj-fold.vim
Created July 4, 2012 19:42 — forked from dakrone/gist:519858
Automagic Clojure folding on defns and defmacros
" ---------------------------------------------------------------------------
" Automagic Clojure folding on defn's and defmacro's
"
" Blog post: http://writequit.org/blog/?p=413
function GetClojureFold()
if getline(v:lnum) =~ '^\s*(defn.*\s'
return ">1"
elseif getline(v:lnum) =~ '^\s*(def\(macro\|method\|page\|partial\).*\s'
return ">1"
@xsc
xsc / main.clj
Created November 18, 2012 22:40
Counting Characters in Clojure
(ns character-counter.main)
;; ------------------------------------------------------------------------
;;
;; SEE HERE: http://dev.xscheme.de/2012/11/counting-characters-in-clojure/
;;
;; ------------------------------------------------------------------------
;; Different Count Strategies
(def count-a-with-regex
@gavinandresen
gavinandresen / btcpayments.rst
Last active May 28, 2024 17:41
Bitcoin Payment Messages

SEE BIP 70

See https://en.bitcoin.it/wiki/BIP_0070 for the latest version of this document; I'll keep this document so the process of discussion/revision isn't lost.

Bitcoin Payment Messages

This document proposes protocol buffer-based formats for a simple payment protocol between a customer's bitcoin client software and a merchant.

@neilj
neilj / window-controller.js
Last active November 4, 2022 21:41
Cross-tab window controller
function WindowController () {
this.id = Math.random();
this.isMaster = false;
this.others = {};
window.addEventListener( 'storage', this, false );
window.addEventListener( 'unload', this, false );
this.broadcast( 'hello' );
@ohpauleez
ohpauleez / fs.clj
Created December 17, 2012 05:59
This is a preview of my experiments using the Alloy Language and Verifier in Clojure. The goal is to use one common, open spec backend to generate: test.generative tests, core.contract constraints, Alloy specs, extra documentation, etc
(ns sterling.example.filesystem.fs
(:require [clojure.walk :as cwalk]))
;; Overview
;; ==========
;;
;; A common example is to illustrate Alloy's abilities is a simpel filesystem.
;;
;; Below is a pure Clojure implementation of the same system, with the same
;; checks.
@Raynos
Raynos / x.md
Last active January 28, 2023 05:12
A list of minimal DOM libraries

DOM Libraries, the easy way

  • [by. Select elements][1]
  • [fragment. Turn HTML into DOMFragments][2]
  • [class-list. Cross browser HTML5 classList implementation][3]
  • [dom-walk. Traverse the DOM in tree order][4]
  • [xhr. Minimal cross browser, cross domain XHR][5]
  • [insert. Cross browser DOM4 insertion methods][6]
  • [to-array. Convert nodelists into arrays][7]
  • [hidden. Cross browser HTML5 hidden property][8]
var PUBNUB = require("pubnub-browserify")
var config = require("./config")
var duplex = require("pubnub-stream/duplex")
module.exports = communication
function communication(doc, channel) {
var client = PUBNUB.init({
subscribe_key: config.subscribe_key
, publish_key: config.publish_key
@max-mapper
max-mapper / readme.md
Last active January 28, 2024 18:11
How-to: Write a node module with voxel.js

Writing node modules with voxel.js

This is a short guide that will teach you the workflows that have been figured out by the voxel.js community for writing node modules + sharing them on NPM and Github. It is assumed that you have a basic understanding of JavaScript, github and the command line (if not you can check out an introduction to git and the command line or learn JS basics from JavaScript for Cats)

The voxel-tower repository on github contains all the example code from this guide.

Table of contents