Skip to content

Instantly share code, notes, and snippets.

@caligin
caligin / fib_proc.erl
Last active August 29, 2015 14:19
Erlang - Fibonacci with processes example
-module(fib_proc).
-export([fib/2]).
-export([start/0]).
-export([start_link/0]).
%% start will be executed in the calling process,
%% creating a new one where the function init/0,
%% that represents the entry point of the "fibonacci
%% service" will be run. Returns the Pid of the newly
%% created process.
@caligin
caligin / 1-UserProfile.java
Created April 21, 2015 16:31
From Class to State+Functions
// Start from a class, that is state and behaviour together
class UserProfile {
private String username;
private String password;
private Date lastLogIn;
private boolean isLoggedIn;
public UserProfile( String username,
String password,

Keybase proof

I hereby claim:

  • I am caligin on github.
  • I am caligin (https://keybase.io/caligin) on keybase.
  • I have a public key whose fingerprint is 6897 DE5F D543 F3DA 02C1 3FEA 7AD2 E918 B3D5 FFB7

To claim this, I am signing this object:

Stream.of(((URLClassLoader)ClassLoader.getSystemClassLoader()).getURLs()).map(URL::getFile).forEach(System.out::println);
version: "2"
services:
bastion:
image: caligin/shepherd_bastion
fip: <redacted>
links:
- app:shepherd
ports:
- "6022:22"
app:
@caligin
caligin / ps1
Created October 27, 2016 16:32
function __hg_ps1 ()
{
if [ "$(hg root 2> /dev/null)" ]; then
echo -en "(hg:$(hg branch))"
fi
}
function __git_ps1 ()
{
if [ "$(git rev-parse --show-toplevel 2> /dev/null)" ]; then
echo -en "(git:$(git branch | tr '\n' ',' | rev | cut -c 2- | rev | sed 's/,/, /g'))"
[
{ "keys": ["ctrl+shift+up"], "command": "duplicate_line" },
{ "keys": ["ctrl+shift+down"], "command": "duplicate_line" },
{ "keys": ["alt+shift+up"], "command": "swap_line_up" },
{ "keys": ["alt+shift+down"], "command": "swap_line_down" },
{ "keys": ["ctrl+shift+s"], "command": "save_all" },
{ "keys": ["ctrl+e"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys": ["ctrl+1"], "command": "focus_side_bar" }
]
@caligin
caligin / README.md
Last active March 29, 2018 12:17
documentation repo readme template

documentation

architecture decision records (ADRs), diagrams, explanation of processes, any other reference material and reports of past issues never solved

table of contents

  • architecture-decision-records

TODO: this can probably become a template+makefile combo (see actual-cookbook for reference)

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

javascript:(function() {
var size_amplification_factor = 1.1;
var possible = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
Array.prototype.slice.call(document.querySelectorAll('body *:not(iframe)')).reduce(function(m, n){ return m.concat(Array.prototype.slice.call(n.childNodes)); },[]).filter(function(n) {
return n.nodeType === Node.TEXT_NODE && n.parentElement.nodeName !== 'SCRIPT' && n.parentElement.nodeName !== 'STYLE' && n.nodeValue.trim() != '';
}).forEach(function(n) {
var new_content = '';
for(var i = 0; i< (n.nodeValue.trim().length * size_amplification_factor); i++) {
new_content += possible.charAt(Math.floor(Math.random() * possible.length));
}