Skip to content

Instantly share code, notes, and snippets.

View luca3m's full-sized avatar

Luca Marturana luca3m

View GitHub Profile
@caruccio
caruccio / bash-path-vars
Last active December 28, 2023 22:47
Path manipulation with bash vars
$ FILE=/some/path/to/file.txt
###################################
### Remove matching suffix pattern
###################################
$ echo ${FILE%.*} # remove ext
/some/path/to/file
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts
@jboner
jboner / latency.txt
Last active May 5, 2024 03: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
@dspezia
dspezia / tst.cpp
Created December 10, 2011 12:45
Variadic rpush C++ hiredis example
#include <iostream>
#include <vector>
#include <string>
#include <stdexcept>
#include <hiredis.h>
using namespace std;
@jwo
jwo / registrations_controller.rb
Created September 30, 2011 23:11
API JSON authentication with Devise
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@nu7hatch
nu7hatch / Gemfile
Created August 4, 2010 09:32
Padrino authentication with Warden
# ...
gem 'padrino-warden', :git => "git://github.com/zmack/padrino-warden.git"
gem 'authtools'