Skip to content

Instantly share code, notes, and snippets.

View codeadict's full-sized avatar
🕸️
λ: f(f(state)) = f(state)

Dairon M. codeadict

🕸️
λ: f(f(state)) = f(state)
View GitHub Profile
@samuraisam
samuraisam / deep_eq.py
Last active October 10, 2024 15:52
Deep Equality Test for Nested Python Structures
#Copyright (c) 2010-2013 Samuel Sutch [[email protected]]
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
@vlm
vlm / erlang-interview-question.erl
Created April 19, 2011 10:37
Erlang inteview question
%% Given the parsed HTML tree in the following format:
%%
%% Types HTML = [Element]
%% Element = {Tag, [Attribute], [Element | Text]}
%% Tag = atom() % e.g. 'a', 'pre', 'p'
%% Attribute = {Name, Value}
%% Name = atom()
%% Value = string()
%% Text = iolist()
%%
-module(timeit).
-compile(export_all).
%% @doc Dynamically add timing to MFA. There are various types of
%% timing.
%%
%% all - time latency of all calls to MFA
%%
%% {sample, N, Max} - sample every N calls and stop sampling after Max
%%
anonymous
anonymous / gist:3816521
Created October 2, 2012 05:55
agregar digito 9
import sqlite3
import pdb
conn = sqlite3.connect('AddressBook.sqlitedb')
c = conn.cursor()
sql = "select ABMultiValue.value, ABPerson.ROWID from ABPerson,ABMultiValue where ABMultiValue.record_id=ABPerson.ROWID"
ins = "update ABMultiValue set value='%s' where record_id=%s"
l = [9,12]
prefix = ['08','09','06','05','03']
c.execute(sql)
res = c.fetchall()
@chrismytton
chrismytton / 01-README.md
Created October 29, 2012 20:46
Mutt Gmail config with OS X keychain

Mutt/Gmail/OS X Keychain

Create a new keychain item, enter the Keychain Item Name as mutt, the Account Name as your gmail email address and then enter your password, then add the keychain item.

2-step auth

If you're using Google 2-step auth, you'll need to generate an Application-specific password from your Google Account settings and enter that as the password.

@sureshsaggar
sureshsaggar / gist:5493610
Created May 1, 2013 03:40
Forecasting in R: Developing Python API to analyze time series data in Redis
'''
Description: dashboard/* primarily powers the APIs requires to support the growth dashboards.
@author: sureshsaggar
'''
#!/usr/bin/env python
from httpserver import *
from werkzeug.routing import *
import time
import redis
@dergraf
dergraf / hilbert.erl
Created July 19, 2013 12:19
space filling hilbert curve that maps two-dimensional space to a one-dimensional space
-module(hilbert).
-export([curve/1, curve/7, point_to_hilbert/3]).
-define(HILBERTMAP, [
{a, [{{0,0},{0,d}}, {{0,1},{1,a}}, {{1,0},{3,b}}, {{1,1},{2,a}}]},
{b, [{{0,0},{2,b}}, {{0,1},{1,b}}, {{1,0},{3,a}}, {{1,1},{0,c}}]},
{c, [{{0,0},{2,c}}, {{0,1},{3,d}}, {{1,0},{1,c}}, {{1,1},{0,b}}]},
{d, [{{0,0},{0,a}}, {{0,1},{3,c}}, {{1,0},{1,d}}, {{1,1},{2,d}}]}
]).

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
@mrb
mrb / pizza_dough.markdown
Last active January 5, 2022 16:05
Best pizza dough
  • 1 2lb bag good AP flour
  • 1 active dry yeast packet
  • 25 grams salt
  • 600 grams water (just over 2 cups)

Mix the salt, yeast, water and about 3/4 of the flour with the paddle attachment (on your stand mixer, or you can try it by hand which I've never done) for about a minute until it is all mixed, it should be pretty loose.

Let it sit, covered, for about 20 minutes.

Knead it on low for 5-7 minutes, until it starts to even out in texture, then start adding the rest of the flour until the dough starts to pull away from the bowl. It should still be pretty wet though. Knead for another 5-7 minutes on med-low, let it rest again for 20 minutes, then remove it to a floured bench, work it with your hands, shape it, and cut it into 4-5 even sized balls.

@slfritchie
slfritchie / presentation.md
Created March 18, 2014 09:22
Erlang tracing, for the Riak source code reading series, 2014-03-18, Tokyo, Japan

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two