Skip to content

Instantly share code, notes, and snippets.

View szahn's full-sized avatar

Stuart Zahn szahn

View GitHub Profile
@utsengar
utsengar / EncodeBased64Binary.java
Created October 11, 2011 00:27
Encode a file to base64 binary in Java
import org.apache.commons.codec.binary.Base64;
private String encodeFileToBase64Binary(String fileName)
throws IOException {
File file = new File(fileName);
byte[] bytes = loadFile(file);
byte[] encoded = Base64.encodeBase64(bytes);
String encodedString = new String(encoded);
@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"
@jaymcgavren
jaymcgavren / heroku.md
Created May 25, 2012 05:47
A Code TV screencast on getting started with Heroku

Description

Heroku is a simple way to publish your Rails app, and a powerful platform that will allow it to scale. In this episode, Jay McGavren gets you started with your first Heroku app.

Set up your Rails app

Isolate your gem environment

  • You WANT Rails to fail locally if a gem isn't in your Gemfile
@ericelliott
ericelliott / flyweight-factory-module.js
Last active November 6, 2015 21:38
Flyweight Factory Module Pattern
var myPrototype = {
methodA: function methodA() {},
methodB: function methodB() {},
methodC: function methodC() {}
};
createFoo = function createFoo() {
return (Object.create(myPrototype));
};
@ericelliott
ericelliott / new-sucks.js
Created September 13, 2012 09:25
new Breaks Factory Objects
// Create a factory object that can be used to swap out the prototype used
// to instantiate new instances.
var factory = {};
factory.proto = {foo: 'bar'};
factory.create = function () { return Object.create(this.proto); };
var t1 = factory.create();
@lenards
lenards / greybeard
Last active March 21, 2024 18:04
Greybeard Definition
Greybeard
An aging [unix hacker] type with an impressive [unix beard] that has now turned grey. Originally a young [neckbeard], these [Gandalf] resembling [curmudgeons] are renowned for their knowledge of theoretical computer science, arcane unix and complete inability to use a remotely contemporary computer.
Typically employed in academia, they are a dying breed from an antediluvian age of 8" [floppies], magnetic tape and timeshared computing. Despite having invented multiuser OSes and the internet, Greybeards prefer to live in the past, where they consider [Fortran] to be a high level programming language. Typical Greybeard computers are dated [Sun workstations] or old PCs running a command line only [BSD] variant, Greybeards shun GUIs, unless they're horrible and dated, like CDE or [Amiga] Workbench.
Some, like Edsger Dijkstra do most of their computer science as entirely theoretical exercises on paper and haven't programmed a computer since 1972.
Contacting a gr
@jelbourn
jelbourn / api-provider.js
Last active February 25, 2024 12:51
Example of using an angular provider to build an api service. Subject of August 20th 2013 talk at the NYC AngularJS Meetup. http://www.meetup.com/AngularJS-NYC/events/134578452/See in jsbin: http://jsbin.com/iWUlANe/5/editSlides: https://docs.google.com/presentation/d/1RMbddKB7warqbPOlluC7kP0y16kbWqGzcAAP6TYchdw
/**
* Example of using an angular provider to build an api service.
* @author Jeremy Elbourn (@jelbourn)
*/
/** Namespace for the application. */
var app = {};
/******************************************************************************/
@staltz
staltz / introrx.md
Last active June 13, 2024 19:58
The introduction to Reactive Programming you've been missing
@oleganza
oleganza / impulse_review.md
Last active January 23, 2016 06:24
Impulse Review

(That's my attempt to understand what problem Impulse solves and how. I am not a designer/developer of this scheme.)

Problem

Regular Bitcoin transactions are not guaranteed until mined sufficiently deep in the blockchain. Unconfirmed transactions can be observed nearly instantly, but they cannot be trusted (could drop out because of insufficient fees, or double-spent).

Impulse Overview

@laughinghan
laughinghan / InterVer.md
Last active January 6, 2024 07:22
Interface Versioning - Never break backcompat, keep the API nimble

Interface Versioning (InterVer)

Never break backcompat, keep the API nimble

An extension of SemVer with a stricter (yet more realistic) backcompat guarantee, that provides more flexibility to change the API, for libraries that are packaged and downloaded (not services accessed remotely over the Internet (see Note 4)).