Skip to content

Instantly share code, notes, and snippets.

@rpip
rpip / arithmetic_protocol.ex
Last active Dec 10, 2015
Arithmetic protocol for Elixir
View arithmetic_protocol.ex
defprotocol Arithmetic.Add do
@moduledoc """
The Arithmetic.Add protocol is responsible for adding items.
The only function required to be implemented is
`__add__` which does the addition.
"""
def __add__(left, right)
end
@rpip
rpip / passwd.py
Last active Aug 29, 2015
Generate passwords for KeePass database. Output: (password, hash)
View passwd.py
#!/usr/bin/env python
# USAGE: ./bin/passwd $password_prefix $dbpath $inventory_hostname -w
import sys, os
import string
import random
from datetime import datetime
from keepass import kpdb
from passlib.hash import sha256_crypt
@rpip
rpip / asm-notes.md
Last active Aug 29, 2015
my study notes ASM x86/i386
View asm-notes.md

x86 / IA-32 registers

  • register is 32 bit wide

general registers

  1. eax - accumulator
  2. ebx - base
  3. ecx - counter
  4. edx - data
  5. esi - source index
@rpip
rpip / emacs-notes.md
Last active Aug 29, 2015
Notes on learning Emacs
View emacs-notes.md

Notes on learning Emacs

basics

C-x f => open file

C-x s => save file

C-x C-w => save to a new file

View edfs.md

Design

The new eDFS architecture is designed with the assumption that a single master system has a single point of failure. In a single-point-of-failure system, the failure of the master node will result in the termination of jobs and the loss of access to the entire system. This will not happen in a cluster where the master node is dynamically elected.

Therefore, each node in the cluster will be a self-containing full copy of eDFS. On startup, the system reads the cluster configuration and sets up the node cluster. All nodes start as followers; one node is elected to be a leader at the start. During normal operation, the leader maintains a heartbeat which allows the followers to detect if the leader fails or becomes partitioned.

View defstructplusplus.ex
defmodule DefStructPlusPlus do
@doc """
Macro for defining structs
## Examples
defmodule Models do
import DefStructPlusPlus
@rpip
rpip / service_phpbb_auth.erl
Last active Aug 29, 2015
Expose Zotonic authentication via a REST API service. This example is built for use with phpBB authentication as documented here: https://wiki.phpbb.com/Authentication_plugins
View service_phpbb_auth.erl
-module(service_phpbb_auth).
-svc_title("External Zotonic Authentication service").
%% You can change this to restrict access
-svc_needauth(false).
-export([process_get/2]).
-include_lib("zotonic.hrl").