Skip to content

Instantly share code, notes, and snippets.

View alex-quiterio's full-sized avatar
🌀
rise to see and not to be seen

aIex quiterio alex-quiterio

🌀
rise to see and not to be seen
  • Seenons
  • Amsterdam
  • 07:53 (UTC +02:00)
View GitHub Profile
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
@alex-quiterio
alex-quiterio / rooby.rb
Last active September 4, 2026 08:58 — forked from jcoglan/_test.rb
# A simplified version of Ruby's object system, implemented in Ruby. This only
# supports a subset of Ruby, but is intended to accurately model inheritance
# and method lookup in as little code as possible, for ease of understanding by
# Ruby programmers.
#
# Classes implemented:
#
# * Object
# * Module < Object
# * Class < Module
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(', ')
}
# A password hashing function insipred by Lamport OTP (a.k.a. hash chains)
# Memory factor: length of the Lamport OTP sequence
# Compute factor: number of independent Lamport OTP sequences to compute
# Hash: a keyed hash function
#
# Finally, all of the Lamport OTP chains calculated are concatenated and hashed
# to produce the resulting digest
#
# Just for fun, this has been implemented with threads to demonstrate how easily
# it can be parallelized, much like CTR mode (NOTE: you will need JRuby or Rubinius
var self = window;
(function(self) {
var canvas, context, particles = [], explode = true, FPS = 60;
/*
* Init.
*/

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
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

class ApplicationController < ActionController::Base
caches_action :render_html,
:cache_path => Proc.new { "#{LastChange::last_update}/pages/#{params[:cms_path]}" },
:if => Proc.new { controller_name == "cms_content" }
end
public class Test {
@Assertion("foo>0")
int foo=1;
@Assertion("bar%2==0")
long bar;
@Assertion("baz>foo")
int baz;