Skip to content

Instantly share code, notes, and snippets.

View cilindrox's full-sized avatar
💭
:suspect:

Gaston Festari cilindrox

💭
:suspect:
View GitHub Profile
@andymatuschak
andymatuschak / States-v3.md
Last active May 12, 2025 06:11
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

@markthethomas
markthethomas / Dockerfile
Last active October 10, 2015 16:01
Example node dockerfile
#using debian:jessie for it's smaller size over ubuntu
FROM debian:jessie
# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Set environment variables
ENV appDir /var/www/app/current
# Run updates and install deps
@ericelliott
ericelliott / mouse-factory.js
Last active June 9, 2017 04:47
Mouse Factory
let animal = {
animalType: 'animal',
describe () {
return `An ${this.animalType} with ${this.furColor} fur,
${this.legs} legs, and a ${this.tail} tail.`;
}
};
let mouseFactory = function mouseFactory () {
@grugq
grugq / gist:03167bed45e774551155
Last active April 15, 2025 11:22
operational pgp - draft

Operational PGP

This is a guide on how to email securely.

There are many guides on how to install and use PGP to encrypt email. This is not one of them. This is a guide on secure communication using email with PGP encryption. If you are not familiar with PGP, please read another guide first. If you are comfortable using PGP to encrypt and decrypt emails, this guide will raise your security to the next level.

@staltz
staltz / introrx.md
Last active May 15, 2025 10:37
The introduction to Reactive Programming you've been missing
@dedy-purwanto
dedy-purwanto / gist:11312110
Created April 26, 2014 05:00
Bulk remove iTerm2 color schemes.
# There was a day where I have too many color schemes in iTerm2 and I want to remove them all.
# iTerm2 doesn't have "bulk remove" and it was literally painful to delete them one-by-one.
# iTerm2 save it's preference in ~/Library/Preferences/com.googlecode.iterm2.plist in a binary format
# What you need to do is basically copy that somewhere, convert to xml and remove color schemes in the xml files.
$ cd /tmp/
$ cp ~/Library/Preferences/com.googlecode.iterm2.plist .
$ plutil -convert xml1 com.googlecode.iterm2.plist
$ vi com.googlecode.iterm2.plist
#echo -ne "\x1bP\x1b]4;0;rgb:00/00/00\a\x1b\\"
#echo -ne "\x1bP\x1b]4;1;rgb:7a/00/00\a\x1b\\"
#echo -ne "\x1bP\x1b]4;2;rgb:00/7a/00\a\x1b\\"
#echo -ne "\x1bP\x1b]4;3;rgb:7a/7a/00\a\x1b\\"
#echo -ne "\x1bP\x1b]4;4;rgb:00/00/7a\a\x1b\\"
#echo -ne "\x1bP\x1b]4;5;rgb:7a/00/7a\a\x1b\\"
#echo -ne "\x1bP\x1b]4;6;rgb:00/7a/7a\a\x1b\\"
#echo -ne "\x1bP\x1b]4;7;rgb:c5/c5/c5\a\x1b\\"
#echo -ne "\x1bP\x1b]4;8;rgb:7a/7a/7a\a\x1b\\"
#echo -ne "\x1bP\x1b]4;9;rgb:ff/00/00\a\x1b\\"
@sd
sd / styles.less
Last active August 29, 2015 13:56
My @atomeditor styles.less
/* I prefer a more compact tree-view */
.tree-view {
font-size: 11px;
.list-item {
line-height: 18px !important;
}
.selected:before, .selected:before {
height: 18px !important;
@arobson
arobson / abstractions.md
Last active October 14, 2021 06:46
Rabbit.MQ + Node.js Notes

Abstraction Suggestions

Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.

Broker

As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:

  • publish
  • request
  • start/stop subscription
@markselby
markselby / node-express-redis-cache.js
Created October 28, 2013 02:19
Add Redis request caching to Node.js with Express.js.
var zlib = require('zlib');
var redis = require('redis');
var redisClient = redis.createClient();
var crypto = require('crypto');
// Our custom caching write function
function cached(body, lifetime, type) {
var key = this.req.originalUrl;
var res = this;
var etag, len;