Skip to content

Instantly share code, notes, and snippets.

View abdollar's full-sized avatar

Abdul Chaudhry abdollar

View GitHub Profile
@abdollar
abdollar / rvm
Created March 8, 2011 04:12
Quick rvm helper commands
rvm install 1.9.2 -C --with-readline-dir=/opt/local,--build=x86_64-apple-darwin10
rvm use --create 1.9.2@rails3
rvm use --create 1.9.2@rails2
rvm use system
rvm use 1.9.2@rails3
@abdollar
abdollar / Disable the oom killer
Created March 8, 2011 04:13
Disable the oom killer on linux
disable oom-killer
Run as root or add to script - for passenger
for pid in $(pidof PassengerNginxHelperServer) ; do echo "disabling oom on pid $pid"; echo -17 | tee /proc/$pid/oom_adj > /dev/null; done
@abdollar
abdollar / Delete by Query - SOLR
Created March 8, 2011 04:16
Delete by Query to delete from SOLR
delete from solr - delete by query
curl http://hostname:port/solr/update --data-binary '<delete><query>id:123456</query></delete>' -H 'Content-type:text/xml; charset=utf-8'
curl http://hostname:port/solr/update --data-binary '<commit waitFlush="false" waitSearcher="false" expungeDeletes="true"/>' -H 'Content-type:text/xml; charset=utf-8'
@abdollar
abdollar / rvm redirects
Created June 2, 2011 18:27
Install rvm on macosx 10.6
bash < <( curl -L http://rvm.beginrescueend.com/releases/rvm-install-head )
@abdollar
abdollar / blueprint lucid
Created December 7, 2011 21:51
Install blueprint on ubuntu lucid
echo "deb http://packages.devstructure.com lucid main" | sudo tee /etc/apt/sources.list.d/devstructure.list
sudo wget -O /etc/apt/trusted.gpg.d/devstructure.gpg http://packages.devstructure.com/keyring.gpg
sudo apt-get update
sudo apt-get -y install blueprint
@abdollar
abdollar / Haskell
Created December 8, 2011 22:16
Add all the natural numbers below one thousand that are multiples of 3 or 5.
sum [n | n <- [3..999], n `mod` 5 == 0 || n `mod` 3 == 0]
@abdollar
abdollar / gist:1449180
Created December 8, 2011 23:14
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
vals = [0, 1]
34.times do
val = vals[-1] + vals[-2]
vals.push(val) if val < 4000000
end
vals.select{|item| item % 2 == 0 }.inject(:+)
@abdollar
abdollar / ruby
Created December 8, 2011 23:51
What is the largest prime factor of the number 600851475143 ?
octave:2> max(factor(600851475143))
@abdollar
abdollar / gist:1463968
Created December 12, 2011 01:09
Find the largest palindrome made from the product of two 3-digit numbers
def palindrome?(str); str.reverse == str; end
max = 0
900.upto(999) { |a|
a.upto(999) { |b|
max = [max, a * b].max if palindrome?((a * b).to_s)
}
}
max
@abdollar
abdollar / Ruby
Created December 13, 2011 02:47
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
(400..2432902008176640000).step(20).each do |i|
val = (1..20).to_a.select{|x| i%x==0}&(1..20).to_a
if val.count == 20
puts i
exit
end
end
Use the product of the LCM's