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
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(', ')
}
# 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
source :rubygems
gem 'rails', '3.0.4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'ar-octopus', :git => 'git://github.com/tchandy/octopus.git', :require => "octopus"
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--
According with the number used on the property
ServersNumber the bootstrapper will fetch this XML
and look for servers to initialize
-->
<add key="ServersNumber" value="1" />

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

--type-add=css=.sass,.less,.scss
--type-add=ruby=.rake,.rsel,.builder,.thor
--type-add=html=.haml,.html.erb,.html.haml
--type-add=js=.js.erb,.coffee
--type-set=cucumber=.feature
--type-set=c=.c,.cpp,.ino,.pde,.h
--ignore-dir=vendor
--ignore-dir=log
--ignore-dir=tmp
--ignore-dir=doc