Skip to content

Instantly share code, notes, and snippets.

View jeremyroman's full-sized avatar

Jeremy Roman jeremyroman

View GitHub Profile
jeremyroman / gist:815849
Created February 8, 2011 04:24
One possible way of describing languages
View gist:815849
languages = {
"C": {
'main_file': "{bot}.c",
'nuke_globs': ["*.o", "{bot}"],
'compile': [
System("gcc -O3 -c {file}", glob="*.c"),
System("gcc -O2 -lm -o {bot}", glob="*.o"),
'run': "./{bot}",
View gist:1057181
var f = function() {}; = { apples: 0, bananas: 0 };
var f1 = new f();;
var f2 = new f();
console.log(; // 1
This is because the food object is modified in-place, and both instances refer to the same object.
View gist:1066483
// a.js
exports.message = 'hello world!';
exports.b = require('./b');
// b.js
var a = require('./a');
module.exports = function() { return a.message; }
jeremyroman / mymodule.js
Created July 6, 2011 14:31
Example of CommonJS modules
View mymodule.js
var nextNumber = 0;
module.exports.getNumber = function() {
nextNumber += 1;
return nextNumber;
View gist:1067452
var http = require('http'),
qs = require('querystring');
var body = qs.stringify({ method: 'system.connect' });
var options = {
host: '',
port: 80,
path: '/services/json/',
method: 'POST',
headers: {
jeremyroman / sass_http.rb
Created July 28, 2011 15:54
An HTTP importer for Sass
View sass_http.rb
# Additional caching and such might be helpful for performance.
# Sass's regeneration only on changed files should work as long as the server provides the Last-Modified header
require 'net/http'
require 'time'
require 'sass'
module Sass
module Importers
# Importer which issues HTTP requests
jeremyroman / gist:1239662
Created September 24, 2011 18:18
Java hello world
View gist:1239662
import java.lang.*;
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world!");
jeremyroman / gist:1240690
Created September 25, 2011 15:02
View gist:1240690
public class BananaMerchant {
private final BananaFactory bananaFactory;
private final ShippingAgent shippingAgent;
private final PricingBroker pricingBroker;
private final List<Banana> bananas;
private final Map<Integer, Customer> customerMap;
public BananaMerchant(
final BananaFactory bananaFactory,
final ShippingAgent shippingAgent,
View gist:1479694
$ g++ -c In member function ‘lvector<B> Monad<lvector>::bind(lvector<A>, Function)’: error: expected `;' before ‘it_a’ error: ‘it_a’ was not declared in this scope error: expected `;' before ‘it_b’ error: ‘it_b’ was not declared in this scope
#include <string>
#include <vector>
View gist:1479822
#include <iostream>
#include <string>
#include <vector>
template <template <typename> class M>
class Monad {
template <typename A, typename B, typename Function>
static M<B> monad_bind(M<A> in, Function function);