Skip to content

Instantly share code, notes, and snippets.

View ejpcmac's full-sized avatar
🎯
Focusing

Jean-Philippe Cugnet ejpcmac

🎯
Focusing
View GitHub Profile
@ejpcmac
ejpcmac / shell.nix
Last active September 26, 2018 21:08
Shell for Nerves projects
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
elixir = beam.packages.erlangR21.elixir_1_7;
in
mkShell {
@ejpcmac
ejpcmac / shell.nix
Last active September 26, 2018 20:48
Shell for standard Elixir projects with file_system and ExUnit Notifier
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
inherit (lib) optional optionals;
elixir = beam.packages.erlangR21.elixir_1_7;
in
mkShell {
@ejpcmac
ejpcmac / shell.nix
Created September 26, 2018 20:29
Bare minimum shell for Elixir projects
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
let
# I like to define variables for derivations that have
# a specific version and are subject to change over time.
elixir = beam.packages.erlangR21.elixir_1_7;
in
@ejpcmac
ejpcmac / fixtures.ex
Created July 1, 2018 15:35
Recursively defining fixtures
defmodule Fixtures do
def user do
quote do
def user, do: :user
end
end
def client do
quote do
# You can use fixtures recursively.
@ejpcmac
ejpcmac / loop.ll
Last active March 27, 2018 17:22
Rust loop performance
; test_loop::sum_manual
; Function Attrs: noinline uwtable
define internal fastcc void @_ZN9test_loop10sum_manual17h519a3902bc8dc8acE(%"alloc::string::String"* noalias nocapture dereferenceable(24), i64** dereferenceable(8) %rng, i8 %n) unnamed_addr #5 {
start:
%sum = alloca i32, align 4
%1 = bitcast i32* %sum to i8*
call void @llvm.lifetime.start(i64 4, i8* nonnull %1)
store i32 0, i32* %sum, align 4
%2 = icmp eq i8 %n, 0
br i1 %2, label %bb2, label %bb3.preheader
@ejpcmac
ejpcmac / passphrase.rs
Created March 15, 2018 22:21
Procedural vs functional Rust for passphrase generation
// Let’s say we have a word list.
let word_list: Vec<String> = ...;
// We want to generate a random passphrase using words from the list.
// Let’s see how to do this with equal performance in two different styles:
// procedural and functional Rust.
// In both cases we need a random generator.
let mut rng = rand::thread_rng();
@ejpcmac
ejpcmac / bazik.zsh-theme
Created July 17, 2017 11:02
Bazik ZSH theme
###################
# Bazik ZSH theme #
###################
# Colored ls
# a black
# b red
# c green
# d brown
# e blue
@ejpcmac
ejpcmac / my_app
Created May 1, 2017 08:38
FreeBSD startup script for Elixir/OTP release
#!/bin/sh
#
# PROVIDE: my_app
# REQUIRE: networking
# KEYWORD:
. /etc/rc.subr
name="my_app"
rcvar="${name}_enable"