Skip to content

Instantly share code, notes, and snippets.

= (λx.x x)(λx.x x)

Nathan Lilienthal nixpulvis

= (λx.x x)(λx.x x)
View GitHub Profile
View shell.rb
# Commands to be executed directly by this shell.
# The builtin `cd` for changing the shell's working directory.
BUILTINS['cd'] = lambda do |args|
# Change to the home directory by default.
args << ENV['HOME'] if args.empty?
# Read the destination path, doing very basic path expansion.
dest = args.pop.gsub(/~/, ENV['HOME'])
nixpulvis / fib
Last active Jun 26, 2018
Fibonacci (again)
View fib
#!/usr/bin/env elixir
defmodule Math do
def fibfast(n) do fib_acc(1, 0, n) end
def fib_acc(a, b, 0) do a + b end
def fib_acc(a, b, n) do fib_acc(b, a+b, n-1) end
def fibslow(0) do 1 end
def fibslow(1) do 1 end
def fibslow(n) do fibslow(n-1) + fibslow(n-2) end
View slack-one.colors
View server.rb
require "socket"
PORT = 1234
server =, Socket::SOCK_STREAM)
# NOTE: Commentting out this line will prevent multiple processes to run at
# once on the same port.
server.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEPORT, true)
server.bind(Addrinfo.tcp("", PORT))
nixpulvis / segv.c
Last active Mar 19, 2020
Intel pthreads Issue
View segv.c
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
static pthread_t thread;
static pthread_mutex_t mutex;
void* work(void* ptr)
nixpulvis / data.json
Created Sep 8, 2017
D3 Hierarchical Data
View data.json
"name": "Root Node",
"children": [
{ "name": "Child 1", "children": [] },
{ "name": "Child 2", "children": [
{ "name": "Child 3", "children": [] }
nixpulvis /
Created May 29, 2017
Compare the speed of various BF implementations in Rust.
extern crate test;
extern crate brainfuck;
extern crate bf;
use test::Bencher;
const HELLO_WORLD: &'static str = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]
nixpulvis / seali.rb
Last active Dec 16, 2016
CLIs with subcommands that don't suck.
View seali.rb
# NOTE: This is a WIP, please pardon our dust.
# Example:
# git --namespace=foobar clone
# #<Git @args=[], @flags={namespace: "foobar"}, @sub=#<Clone @args=[""], @flags=[], @sub=nil>>
class Seali
class << self
attr_accessor :subs
nixpulvis / first_or_create.rb
Last active Jul 26, 2016
Retrying a first or create when two happen at the same time.
View first_or_create.rb
# Simple helper function for retrying a first or create when two happen
# at the same time and one violates the database unique index constraint.
def first_or_create(scope, attributes = {})
rescue ActiveRecord::RecordNotUnique
nixpulvis /
Created Apr 20, 2016
debug! an expression and it's syntax.
macro_rules! debug_expr {
($expr:expr) => {{
let value = $expr;
debug!("`{}` = {:?}", stringify!($expr), value);
You can’t perform that action at this time.