Skip to content

Instantly share code, notes, and snippets.

View alex-quiterio's full-sized avatar
🌀
using my coding skills to fight for the climate

aIex quiterio alex-quiterio

🌀
using my coding skills to fight for the climate
View GitHub Profile
Latency Comparison Numbers
--------------------------
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@alex-quiterio
alex-quiterio / puddles.go
Created August 3, 2014 00:14
Simple programming exercise with unionSets
package main
import "fmt"
type Set struct {
pos int
value int
}
func makeSet(position int, value int) Set {
--- module ScottsSnake where
import Keyboard
import Random
import String
import Set
type Position = {x: Int, y: Int }
type Board = {w: Int, h: Int, wall: [Position]}
type Apple = Position
class Allocator
# override new class method
def self.new(*args)
print "Hello "
ref = allocate
ref.send(:initialize, *args)
print "\n"
return ref
end

Benchmarking Nginx with Go

Today I just wanted to know which of these options is faster:

  • Go HTTP standalone
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI

Hardware

def swap_string(string)
i = 0
j = string.length - 1
while i < j do
string[i] = (string[i].ord ^ string[j].ord).chr
string[j] = (string[i].ord ^ string[j].ord).chr
string[i] = (string[i].ord ^ string[j].ord).chr
i+=1
j-=1
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do
package main
import (
"flag"
"fmt"
"io/ioutil"
"net/http"
"runtime"
"sync"
"time"

Security is Hard

Massive Assignment

  • watch for ActiveRecord Relation, like has_many, has_many :through
  • watch for user_roles, `group_users
  • UPDATE action

Admin

natural_primer = ->(number) {
primes = [1]
number.times do
next_prime = primes.reduce(:*) + 1
primes << next_prime
end
puts primes[1..-1].join(', ')
}