Skip to content

Instantly share code, notes, and snippets.

View mfbx9da4's full-sized avatar

David Alberto Adler mfbx9da4

View GitHub Profile
nato = {
"a": 'Alfa',
"b": 'Bravo',
"c": 'Charlie',
"d": 'Delta',
"e": 'Echo',
"f": 'Foxtrot',
"g": 'Golf',
"h": 'Hotel',
"i": 'India',
@mfbx9da4
mfbx9da4 / funcy.js
Last active January 3, 2016 07:19
A contrived example of some functional techniques.
first = function (a) {
return function (b) {
return function (c) {
if (c < 4) {
return c * (b + a);
} else {
return ((first(a))(b))(c-1);
}
}
}
@mfbx9da4
mfbx9da4 / funcy.go
Created January 16, 2014 19:33
Same contrived functional program but in go
package main
import fmt "fmt"
type IntFunc func(int) int
type HiIntFunc func(int) IntFunc
func first(a int) HiIntFunc {
return func(b int) IntFunc {
return func(c int) int {
@mfbx9da4
mfbx9da4 / non-responsive-print.css
Created January 25, 2014 04:08
Responsiveness override for media print bootstrap3
@media print {
/*remove chrome links*/
a[href]:after {
content: none !important;
}
.col-md-1,
.col-md-2,
.col-md-3,
.col-md-4,
.col-md-5,
@mfbx9da4
mfbx9da4 / marble-solitaire.py
Created January 27, 2014 23:50
A solver for marble solitaire game
import sys
import random
class Ball():
directions = [(-1, 0), (1, 0), (0, 1), (0, -1)]
def __init__(slf):
# None = wall, False == free space, or another Ball instance
slf.north = None
@mfbx9da4
mfbx9da4 / .zshrc
Created April 14, 2014 14:40
.zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="bira"
plugins=(colored-man npm pep8 pip copyfile cp)
source $ZSH/oh-my-zsh.sh
@mfbx9da4
mfbx9da4 / try.js
Created November 12, 2014 19:25
try to execute a callback for a while
var try = function (callback, terminal_case_callback, times, interval) {
var number_of_times_tried = 0;
times = times || 1000;
interval = interval || 5;
var _timeout_id = setInterval(function () {
callback();
if (terminal_case_callback() || number_of_times_tried > times) {
clearInterval(_timeout_id);
}
}, interval)
@mfbx9da4
mfbx9da4 / dijkstra_with_heaps.py
Last active September 11, 2015 17:06
Dijkstra with Heaps for problem set 5 udacity course intro to algorithms
# udacity ps 5.1
#
class BinaryHeap(object):
"""BinaryHeap for maintaining ordered
list of nodes with smallest score at the
top of the heap.
def update_not_x(k, array, num):
if k > len(array) - 1 or array[k] == num:
return 0
else:
return 1
def update_count_x(i, array, num):
if i == 0 or array[i - 1] != num:
return 0
@mfbx9da4
mfbx9da4 / server_date.js
Last active December 15, 2020 14:38
Angular Clock Synchronization using websockets between browser and server (similar to NTP).
/**
* Synchronizes local system time with server time
* using clock synchronization algorithm, similar to
* NTP.
*
* Pings server every half second for server time.
* Calculates offset as difference between server time
* and browser time before and after socket request.
*
* Keeps track of last 5 offsets and calculates current