Skip to content

Instantly share code, notes, and snippets.

// HOWTO: load LABjs itself dynamically!
// inline this code in your page to load LABjs itself dynamically, if you're so inclined.
(function (global, oDOC, handler) {
var head = oDOC.head || oDOC.getElementsByTagName("head");
function LABjsLoaded() {
// do cool stuff with $LAB here
}
@panesofglass
panesofglass / IApplication.cs
Created November 30, 2010 16:59
.NET Web Abstractions
// Func<IRequest, IResponse>
public interface IApplication {
IAsyncResult BeginInvoke(IRequest request, AsyncCallback callback, object state);
IResponse EndInvoke(IAsyncResult result);
}
@topfunky
topfunky / Cakefile
Created April 14, 2011 22:18
Watch both Sass and Coffee files and compile on change (for Node.js)
###
Modified from https://github.com/jashkenas/coffee-script/blob/master/Cakefile
Part of an upcoming PeepCode screencast. This snippet is MIT Licensed.
###
{spawn, exec} = require 'child_process'
task 'assets:watch', 'Watch source files and build JS & CSS', (options) ->
runCommand = (name, args) ->
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using Jurassic;
using Jurassic.Library;
namespace NotActuallyTheDlrCoffee
@jasonmw
jasonmw / FailoverFunc.cs
Created May 10, 2011 20:15
Failover Func
using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Jason.Tests {
[TestClass]
public class TryParseTests {
[TestMethod]
public void TestTryParse_Func_Bad() {
Assert.AreEqual(0, "s".TryParse(Failover<int>));
@ryancrum
ryancrum / jquerytest.cljs
Created July 21, 2011 02:24
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
@jboner
jboner / latency.txt
Last active June 21, 2024 04:31
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

Git Cheat Sheet

Commands

Getting Started

git init

or

@blainerothrock
blainerothrock / gen.swift
Last active July 12, 2018 15:56
A Very Simple Genetic Algorithm Written in Swift 3
#!/usr/bin/env xcrun swift -O
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
The parameters of the simulation can be changed by modifying one of the many