Skip to content

Instantly share code, notes, and snippets.

@remydagostino
remydagostino / beverage-buddies.js
Created December 24, 2020 02:29
Beverage Buddies V2
// Usage: node beverage-buddies.js people-list.txt history.txt showPairingStamped
const { readFileSync } = require('fs');
const process = require('process');
function main(peopleFile, historyFile, command) {
const peopleLines = removeComments(readFileSync(peopleFile).toString().split('\n'));
const historyLines = readFileSync(historyFile).toString().split('\n');
const now = Date.now();
@remydagostino
remydagostino / beverage-buddy.js
Created October 26, 2020 04:08
Social Beverage Programme
// Usage: node matcher.js people-list.txt 2
const people = require('fs').readFileSync(process.argv[2]).toString().split('\n');
const weekNum = Number(process.argv[3]);
const pairs = people
.map((person, index) => people[(index + weekNum) % people.length])
.map((person, index, list) => {
const match = list[list.length - index - 1];
if (match === person) {
@remydagostino
remydagostino / keybase.md
Created October 7, 2020 06:04
keybase.md

Keybase proof

I hereby claim:

  • I am remydagostino on github.
  • I am rdagostino (https://keybase.io/rdagostino) on keybase.
  • I have a public key ASD5nmQlyySYoW4O0t4CzAotq4NrH-bmAuAH5IR2GfWsAQo

To claim this, I am signing this object:

@remydagostino
remydagostino / launcher_idea.bat
Created May 2, 2018 19:09
Dani's powerpoint extravaganza
POWERPNT.exe /s "<name of file goes here>.ppt"
@remydagostino
remydagostino / promise-example.js
Created November 17, 2017 16:58
Learning exercise for promises (advanced)
// Here we try to use first principles to hack together a very scrappy version
// of a javascript Promise which doesn't implement the A+ spec.
// This is a learning exercise and there are many edge-cases for which this code
// does not handle (such as attaching several callbacks to one promise).
// A good challenge for your understanding might be to modify the code so that
// it could allow several callbacks to be attached to a single promise.
// An broken example is shown at the bottom of the file.
@remydagostino
remydagostino / roman-simple.hs
Last active August 12, 2016 22:50
Calculate the roman numeral string for a number
module RomanNumerals.Simple (integerToRomanString) where
import Data.List (find)
import Data.Maybe (maybe)
integerToRomanString :: Integer -> Maybe String
integerToRomanString v =
let
sortedVals :: [(String, Integer)]
sortedVals =
@remydagostino
remydagostino / future.js
Created June 27, 2016 14:54
Minimal continuation passing construct
function thenable(action) {
var self = {
fork: function(succ, err) {
action(succ || function() {}, err || function() {});
},
then: function(fn) {
return thenable(function(resolve, reject) {
self.fork(
function(data) {
var step = fn(data);
@remydagostino
remydagostino / typeclasses.hs
Last active February 21, 2016 17:56
Getting the hang of haskell typeclasses
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module Main where
import Data.Monoid (Monoid, mempty, mappend, mconcat)
------------------------------
-- Part 1: Make a silly monoid instance for Int
@remydagostino
remydagostino / personal-pronouns.md
Last active February 15, 2016 22:32
German Pronoun practice
| Ich  | Du    | Er   | Sie  | Es   | Wir   | Ihr  | Sie

----|------|-------|------|------|------|-------|------|------ | gebe | gibst | gibt | gibt | gibt | geben | gibt | geben | mir | dir | ihm | ihr | ihm | uns | euch | ihnen | es | es | ihn | sie | es | es | es | es für | mich | dich | ihn | sie | es | uns | euch | ihnen

  • Ich gebe mir es für mich
  • Du gibst dir es für dich
  • Er gibt ihm ihn für ihn
@remydagostino
remydagostino / sql-intersect-helper.php
Created September 13, 2013 00:36
A helper class to perform various kinds of intersections across related tables.
<?php
/**
* External logic for a complex search helper - keeps main files cleaner
*/
class SqlIntersectHelper{
// Outersects are the same as intersects but data lists without any entries will always be included in the result
// Any - Any value from the criterion list must exist at least once in the data list