Skip to content

Instantly share code, notes, and snippets.

# Make balanced image directories to improve file system search
#
# Example:
#
# make_balanced_dirs(2, 4)
# ac3294f2b0174ee1.jpg -> ac329/4f2b/ac3294f2b0174ee1.jpg
#
def make_balanced_dirs levels, length
Dir.glob("*.jpg").collect do |f|
/**
* AS3 implementation of Ruby Enumeration class
*/
public dynamic class Enumerable
{
private var _array:Array;
public function Enumerable(... parameters) {
if(parameters != null)
_array = parameters;
function iterComponents() {
var root:Object = arguments[0];
var f:Function = arguments[1];
var cache:Object = arguments[2];
if(!cache)
cache = new Object(); // initialize cache
cache[root] = true; // mark as visited
for(var obj in root) {
// visit unvisited components
/**
* Returns the binary representation of a number
*
* @param A number
* @return A string of 1's and 0's
*/
private function toBinary(n:Number):String {
var s:String = "";
var i:Number = 0;
var b:Number = n >> i;
/**
* Extensions to the AS2 Array class
*/
class ArrayExtensions
{
public function ArrayExtensions() {
}
@edulan
edulan / transpose.php
Created August 10, 2011 12:08
PHP matrix transpose using a functional approach
<?php
$matrix = array(
array('a', 1, 2),
array('b', 3, 4),
array('c', 5, 6),
array('d', 7, 8)
);
$transpose = array_reduce(
$matrix,
sudo add-apt-repository ppa:mozillateam/firefox-next # para el canal beta
sudo add-apt-repository ppa:ubuntu-mozilla-daily/firefox-aurora # para el canal aurora
sudo apt-get update && sudo apt-get upgrade
@edulan
edulan / moviles.txt
Created March 3, 2012 02:59
Whatsapp status crawler
600##GSM/DCS#Asignado#VODAFONE ESPAÑA, S.A.U.#19/11/1998
601#0# #Compartido#TENARIA, S.A.#19/10/2007
601#0#GSM#Asignado#CABLEUROPA, S.A.U.#24/05/2007
601#1# #Compartido#TENARIA, S.A.#19/10/2007
601#1#GSM#Asignado#CABLEUROPA, S.A.U.#24/05/2007
601#2# #Compartido#TENARIA, S.A.#19/10/2007
601#2#GSM#Asignado#CABLEUROPA, S.A.U.#24/05/2007
601#6# #Subasignado 0,1,2,3,4,5,6,7,8,9#LEAST COST ROUTING TELECOM, S.L.#22/02/2012
601#6#Sin definir#Asignado#FRANCE TELECOM ESPAÑA, S.A. UNIPERSONAL#22/02/2012
602#1#Sin definir#Asignado#LYCAMOBILE, S.L.#20/12/2011
@edulan
edulan / bookmarklet.js
Created November 27, 2014 13:47
Logentries bulk update for Tags & Alerts
var APP_ID = window.location.pathname.replace("/app/", "");
function appUrl () {
return "https://logentries.com/rest/" + APP_ID;
}
function tagsUrl () {
return appUrl() + "/api/tags";
}