Skip to content

Instantly share code, notes, and snippets.

View fedragon's full-sized avatar

Federico Ragona fedragon

View GitHub Profile
@jboner
jboner / latency.txt
Last active July 23, 2024 14:12
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
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 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 22, 2024 23:19
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@pjaspers
pjaspers / gist:6624364
Created September 19, 2013 14:29
Joe Armstrong on programmer productivity
Once upon a very long time ago we did a project to compare the efficiency of
Erlang to PLEX.
We implemented "the same things" (TM) in Erlang and PLEX and counted total man hours
We did this for several different things.
Erlang was "better" by a factor of 3 or 25 (in total man hours) - the weighted average was a factor 8
They asked "what is the smart programmer effect"
@jeroenr
jeroenr / Build.scala
Last active August 30, 2016 08:53
Parameter validation with Play 2 framework
object ApplicationBuild extends Build {
val appName = "my-app"
val appVersion = "1-SNAPSHOT"
val appDependencies = Seq(
jdbc,
cache
)
val main = play.Project(appName, appVersion, appDependencies)
@dpwiz
dpwiz / Main.elm
Created March 18, 2015 19:27
Render, minify and compress Elm project.
module Main where
import Html (..)
import Html.Attributes (..)
import Html.Events (..)
import List
import LocalChannel as LC
import Signal
-- Model
@yang-wei
yang-wei / destructuring.md
Last active July 4, 2024 16:56
Elm Destructuring (or Pattern Matching) cheatsheet

Should be work with 0.18

Destructuring(or pattern matching) is a way used to extract data from a data structure(tuple, list, record) that mirros the construction. Compare to other languages, Elm support much less destructuring but let's see what it got !

Tuple

myTuple = ("A", "B", "C")
myNestedTuple = ("A", "B", "C", ("X", "Y", "Z"))
@DonDebonair
DonDebonair / gen_slav.scala
Created April 1, 2016 11:04
Generate a sentence in a Slavic language
(0 to 300).map(_ => scala.util.Random.nextPrintableChar).filter(Set('k', 'v', 's', 'e', 'y', 't', 'p', 'a', 'u', 'o').contains).grouped(5).map(_.mkString("")).mkString(" ")
@sdorra
sdorra / keys.go
Created April 17, 2016 19:31
Golang RSA Key Generation
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@matthiassb
matthiassb / dns-sync.sh
Last active July 3, 2024 23:29
Init.d script for keeping WSL resolv.conf in-sync with Windows
#! /bin/bash
### BEGIN INIT INFO
# Provides: dns-sync
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Synchronizes /etc/resolv.conf in WLS with Windows DNS - Matthias Brooks
### END INIT INFO