Skip to content

Instantly share code, notes, and snippets.

@zaphar
zaphar / date_util.erl
Created May 1, 2009 06:07
set of utility functions that wrap the calendar module and erlangs now() date() and time() functions
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.
@ckirkendall
ckirkendall / clojure-match.clj
Created June 15, 2012 02:26 — forked from bkyrlach/Expression.fs
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 10, 2024 16:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active May 5, 2024 13:30
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@t0yv0
t0yv0 / subtyping.v
Last active February 28, 2021 01:47
Demonstrating TypeScript 0.8 type system to be unsound. The subtyping relationship is defined in a way that admits the following code that results in TypeError exception being thrown.
Require Import Utf8.
Inductive subtype (a b : Set) : Set :=
| ST : (a -> b) -> subtype a b.
Infix ":>" := subtype (at level 50).
Definition st {x y} f := ST x y f.
Definition unpack {a b : Set} (st : a :> b) :=
%%% led_controller is a module to toggle LEDs wired to gpio pins on the raspberry pi
-module(led_controller).
-behavior(gen_server).
-export([start_link/1]).
% standard gen_server
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
% Public Interface
-export([on/1, off/1, blink/2]).
% Don't call these directly
-export([blink_cast/2]).
@NicolasT
NicolasT / _tags
Last active February 4, 2020 00:26
RWST for state machines in OCaml
true: package(lwt)
true: package(lwt.unix)
<rwst.ml>: camlp4orf, use_monad
@kaos
kaos / Vagrantfile
Created May 30, 2013 18:58
Vagrant setup for zotonic
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
@valtron
valtron / gist:5688638
Last active January 24, 2017 23:53
typescript-unsound-generics.ts
class Box<T> { constructor(public value: T) {} }
class A {}
class B { foo() {} }
var bb : Box<B> = new Box<B>(null);
// This typechecks (it shouldn't; T is used both in a co- and contra-variant position, so it's invariant)...
var ba : Box<A> = xb;
ba.value = new A();
@raichoo
raichoo / gist:5700522
Last active December 18, 2015 00:59
JavaScript Lib
module Main
{-
Compile with:
idris --package javascript --target javascript test.idr -o test.js
<html>
<head>