Skip to content

Instantly share code, notes, and snippets.

View albemuth's full-sized avatar

Alfredo Mesen albemuth

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@albemuth
albemuth / setup-vmware-image-with-static-IP.markdown
Last active June 14, 2016 15:08 — forked from pjkelly/setup-vmware-image-with-static-IP.markdown
VMWare Fusion Images with a static IP Address on Mac OS X Snow Leopard

How to setup your VMWare Fusion images to use static IP addresses on Mac OS X

At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.

When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name ubuntu-lucid-lynx-base a

@albemuth
albemuth / inUrl.js
Last active December 23, 2015 18:49 — forked from leopic/inUrl.js
_.mixin({
inUrlDry: function(singleParam) {
//en vez de usar un arreglo para manegar los keys, vals se crea un map, así
//se puede accesar directamente en vez de tener que buscar con index of,
//esa parte pasa de O(n) a O(1) primero se hace un arreglo que tiene una
//estructura así: [[param, {decodedValue: 'val', rawValue: 'val'}]...] y el
//metodo _.object pasa de eso a
//{param: {decodedValue: 'val', rawValue: 'val'}}
var paramMap = _.chain(location.search.slice(1).split('&'))
@albemuth
albemuth / stronglifts5x5.rb
Created July 11, 2011 23:50
stronglifts5x5.rb
days = ["Mon", "Wed", "Fri"]
exercises = [:squat, :bench_press, :barbell_rows, :overhead_press, :deadlift]
weights = {}
workout_a = [:squat, :bench_press, :barbell_rows]
workout_b = [:squat, :overhead_press, :deadlift]
exercises.each do |e|
# http://projecteuler.net/index.php?section=problems&id=11
# Problem 11
# What is the greatest product of four adjacent numbers in any direction (up, down, left, right, or diagonally) in the 20X20 grid?
m = [ [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[ 1, 1, 1, 8, 2,22,97,38,15, 0,40, 0,75, 4, 5, 7,78,52,12,50,77,91, 8, 1, 1, 1],
[ 1, 1, 1,49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48, 4,56,62, 0, 1, 1, 1],
[ 1, 1, 1,81,49,31,73,55,79,14,29,93,71,40,67,53,88,30, 3,49,13,36,65, 1, 1, 1],
# Problem 5
# What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?
(1...100000000).each do |i|
n = i * 20
(print n; exit) if [19,18,17,16,15,14,13,12,11].inject(true) do |divisible, i|
divisible && (n % i == 0)
end
end
@albemuth
albemuth / vib.rb
Created August 24, 2009 19:41
vibram scrape
#!/usr/bin/ruby
require 'net/http'
require 'uri'
class Array
def map_to_hash
map { |e| yield e }.inject({}) { |carry, e| carry.merge! e }
end
end
@albemuth
albemuth / aeropost_expand_history.user.js
Created May 23, 2009 23:05
aerocasillas history fixer
// ==UserScript==
// @name expand_history
// @namespace aerocasillas
// @include https://www.myaeropost.com/MyAero/trackingInformation.aspx*
// ==/UserScript==
document.getElementById('div_hist').style.display = 'inline';
ROOT = '../'
Shoes.setup do
gem 'activerecord'
end
require 'active_record'
require 'note'
Shoes.app do
ActiveRecord::Base.establish_connection(
@albemuth
albemuth / crautos.user.js
Created March 24, 2009 06:10
crautos.com tiene muchos problemas de usabilidad, este script arregla unos cuantos
// ==UserScript==
// @name crautos
// @namespace crautos
// @include http://crautos.com/usados/economicos-usearch.cfm
// @include http://crautos.com/usados/economicos-usearch2.cfm*
// @include http://crautos.com/usados/economicos-usearch2.cfm*
// @include http://www.crautos.com/usados/economicos-usearch.cfm
// @include http://www.crautos.com/usados/economicos-usearch2.cfm*
// @include http://www.crautos.com/usados/economicos-usearch2.cfm*
// ==/UserScript==