Skip to content

Instantly share code, notes, and snippets.

@emersonmoretto
emersonmoretto / benchmark.sh
Created August 9, 2011 21:06
Apache bench + Gnuplot Script
#!/bin/bash
echo -e "\nbenchmark.sh -n<number of requests> -c<number of concurrency> <URL1> <URL2> ..."
echo -e "\nEx: benchmark.sh -n100 -c10 http://www.google.com/ http://www.bing.com/ \n"
## Gnuplot settings
echo "set terminal png
set output 'benchmark_${1}_${2}.png'
set title 'Benchmark: ${1} ${2}'
@jboner
jboner / latency.txt
Last active March 17, 2025 23:22
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
@digitaljhelms
digitaljhelms / gist:4287848
Last active March 17, 2025 07:59
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
@emil2k
emil2k / Connectivity.java
Last active August 5, 2024 10:48
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
@dyve
dyve / bootstrap-tables2.css
Created April 25, 2013 08:00
Bootstrap template for django-tables2 (https://github.com/bradleyayers/django-tables2), currently depends on django-bootstrap-toolkit (https://github.com/dyve/django-bootstrap-toolkit)
.table-container th.asc:after {
content: '\0000a0\0025b2';
}
.table-container th.desc:after {
content: '\0000a0\0025bc';
}
.pagination {
text-align: center;
}
from fabric.api import local
import pip
def freeze ():
local("pip freeze > requirements.txt")
local("git add requirements.txt")
local("git commit -v")
def upgrade ():
for dist in pip.get_installed_distributions():
@afgomez
afgomez / validate_spanish_id.js
Last active February 4, 2025 20:32
Spanish DNI, CIF, NIE validator
/**
* ValidateSpanishID. Returns the type of document and checks its validity.
*
* Usage:
* ValidateSpanishID( str );
*
* > ValidateSpanishID( '12345678Z' );
* // { type: 'dni', valid: true }
*
* > ValidateSpanishID( 'B83375575' );
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@hectoregm
hectoregm / angularfire-crud-es.md
Last active October 3, 2020 19:05
Tutorial for basic CRUD using AngularJS and Firebase

Tutorial para AngularFire (AngularJS + Firebase)

Introduccion

En este tutorial haremos uso de AnguarJS y de Firebase (esta combinacion es tambien llamada AngularFire) para implementar un CRUD basico para el ingreso de usuarios. En este tutorial se tiene como requisitos tener instalado git y tener una cuenta en Firebase

AngularJS

Es un framework MVC que esta implementado en Javascript este vive en el lado del cliente (navegador) y dado que usaremos como backend a Firebase que nos da un BD desde el cliente es solo necesario un servidor web para poder enviar HTML, CSS y el Javascript de la aplicacion. Haremos uso de un servidor web usando Node.js desde la consola para ver como va nuestra aplicacion.

@ckinsey
ckinsey / decorators.py
Created March 22, 2014 16:34
Require SSL for Django views via a decorator. You'll need some setup in your web server to support the request.is_secure() method--see the Django docs.
from functools import wraps
from django.conf import settings
from django.http import HttpResponseRedirect
def require_ssl(view):
"""
Decorator that requires an SSL connection. If the current connection is not SSL, we redirect to the SSL version of
the page.