Skip to content

Instantly share code, notes, and snippets.

@bryanhunter
bryanhunter / mike_check.erl
Created February 11, 2014 19:10
Simple program to test the performance of a concurrent language.
-module(mike_check).
% The performance of a concurrent language is predicated by three things:
% 1) the context switching time,
% 2) The message passing time,
% 3) and the time to create a process.”
% - Mike Williams
-export([start_and_time/1,start/1, do_it_all/2]).
@macintux
macintux / example-erlang-types.md
Last active December 22, 2015 03:18
Erlang type examples, because I can never remember how they work and I utterly fail at reading docs

Doc: http://www.erlang.org/doc/reference_manual/typespec.html

-type square() :: tuple(pos_integer(), pos_integer()).
-type side() :: 'white'|'black'.
-type movefun() :: fun((square(), square(), side()) -> tuple(square(), list(square()))).
-type movedef() :: tuple(atom(), movefun()).

-record(move, { piece,
 start,
@andelf
andelf / beam_decompile.erl
Created March 19, 2013 03:25
Erlang BEAM file decompile to .erl file
#!/usr/bin/env escript
% -*- mode: erlang -*-
main([BeamFile]) ->
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(BeamFile,[abstract_code]),
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
@anaisbetts
anaisbetts / the original guy used autocrlf false
Created May 27, 2012 06:58
.gitattributes to solve your problems
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
@henrik242
henrik242 / p4merge
Last active January 5, 2023 22:23
Helper script for p4merge and Git on MacOSX
#!/bin/bash
for arg; do [[ $arg = /* ]] || arg=$PWD/$arg; absargs+=("$arg"); done;
/Applications/P4Merge.app/Contents/Resources/launchp4merge "${absargs[@]}"
@ThomasBurleson
ThomasBurleson / Another mock approach.js
Created November 16, 2011 23:59 — forked from cowboy/jquery.ba-simple-ajax-mocking.js
Simple jQuery (1.5+) AJAX Mocking (requires JSON, tested in jQuery 1.7))
// mock ajax
$.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
if ( /^\/?mock-ajax/.test( originalOptions.url ) ) {
// make new deferred and save any success/error handlers
var success = options.success,
error = options.error;
// kill off the old handlers
options.success = options.error = null;
@stevenharman
stevenharman / Iso8601DateTimeBinder.cs
Created November 2, 2010 19:25
an asp.net-mvc Model Binder that respects the ISO 8601 standard. look it up, yo!
using System;
using System.Globalization;
using System.Web.Mvc;
namespace Zomg.Web.ModelBinders
{
public class Iso8601DateTimeBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
public static class AutofacScanningExtensions
{
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
RegisterAssemblyTypesFromPath(this ContainerBuilder builder, string path)
{
return RegisterAssemblyTypesFromPath(builder, path, null, a => true);
}
public static IRegistrationBuilder<object, ScanningActivatorData, DynamicRegistrationStyle>
RegisterAssemblyTypesFromPath(this ContainerBuilder builder, string path, Predicate<Assembly> Assemblyfilter)