Skip to content

Instantly share code, notes, and snippets.

View protron's full-sized avatar

Mariano Desanze protron

  • Buenos Aires, Argentina
View GitHub Profile
@delijati
delijati / gist:1629405
Created January 17, 2012 22:28
python idastar vs astar
import sys
import copy
import time
import math
import heapq
import argparse
FINFINITY = 5000
USAGE = "python puzzle8.py [bfs|idfs|astar|idastar]"

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@staltz
staltz / introrx.md
Last active April 29, 2025 08:33
The introduction to Reactive Programming you've been missing
@ericlippert
ericlippert / Combinations.cs
Last active November 29, 2020 02:17
Computing combinations of a sequence in C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
// An immutable stack
//
// Note that the class is abstract with a private
// constructor; this ensures that only nested classes
// may be derived classes.
@chantastic
chantastic / on-jsx.markdown
Last active November 10, 2024 13:39
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I led the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can't

@jfairbank
jfairbank / fibonacci-generator.js
Last active December 4, 2023 12:23
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@protron
protron / .gitconfig
Last active March 30, 2022 20:19
.gitconfig (aliases, editor config, defaults)
[alias]
aliases = config --global --get-regexp 'alias.*'
st = status
co = checkout
ci = commit
skip = update-index --skip-worktree
unskip = update-index --no-skip-worktree
skipped = !git ls-files -v . | grep ^S
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
import { call, put, select } from 'redux-saga/effects';
import { API_BUTTON_CLICK_SUCCESS, API_BUTTON_CLICK_ERROR, } from './actions/consts';
import { getUserAccessToken } from './selectors';
import { getDataFromAPI } from './api';
import { apiSideEffect } from './sagas';
it('apiSideEffect - dispatches API_BUTTON_CLICK_ERROR if we aren\'t authenticated', () => {
const generator = apiSideEffect();
const fakeAccessToken = ''; // or false, null, etc