Skip to content

Instantly share code, notes, and snippets.

View xymor's full-sized avatar

Raphael Miranda xymor

View GitHub Profile
@xymor
xymor / gist:5025721
Last active December 14, 2015 04:08
Ruby Euler #3
#print the largest prime factor a number
#this is the most elegant way and work ok for large numbers
require 'prime'
Prime.prime_division(big_number).max()
# Not using Prime which has pretty bad performance before 1.9
# and using tail recursion which is cool as fast
@xymor
xymor / es.sh
Last active December 12, 2015 01:38 — forked from kajic/es.sh
cd ~
#sudo apt-get update
#sudo apt-get install curl python-software-properties -y
#sudo apt-get install openjdk-6-jre-headless
curl -L https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz | tar -xz
sudo mv elasticsearch-* /usr/local/share/elasticsearch
curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
sudo mv *servicewrapper*/service /usr/local/share/elasticsearch/bin/
rm -Rf *servicewrapper*
@xymor
xymor / gist:4549291
Last active May 25, 2018 19:54
Encrypt/decrypt with Blowfish/ECB/NoPadding
import javax.crypto.spec.SecretKeySpec
import javax.crypto.Cipher
import org.apache.commons.codec.binary.Base64
def encrypt(encrypt,en_key) {
if(encrypt.size() % 8 != 0){ //not a multiple of 8
byte[] padded = new byte[encrypt.length + 8 - (encrypt.length % 8)];
//copy the old array into it
@xymor
xymor / gist:3555170
Created August 31, 2012 16:08
Use libnotify to run tests automaticaly after saving a source
# save it as inotifyrun
--
#!/bin/sh
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written")
"$@"
while inotifywait -qre close_write --format "$FORMAT" .
do
"$@"
done
--
@xymor
xymor / gist:3286394
Created August 7, 2012 15:28
advance a sequence without ddl permissions
-- pardon my noob plsql skills
declare
val number;
begin
for i in 1..100 loop
select B2B_B2W_ADMIN.STOCKDETAIL_SEQ.nextval into val from dual;
end loop;
end;
-- remember to commit
@xymor
xymor / mountain-lion-brew-setup.markdown
Created August 4, 2012 17:52 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

@xymor
xymor / git-daemon
Created June 25, 2012 19:04
git-daemon start script
#!/bin/sh
#
# From: http://robescriva.com/blog/2009/01/13/git-daemon-init-scripts-on-centos-52/
# Startup/shutdown script for Git Daemon
#
# Linux chkconfig stuff:
#
# chkconfig: 345 56 10
# description: Startup/shutdown script for Git Daemon
@xymor
xymor / gist:2897523
Created June 8, 2012 18:42
wait for a service to be available
# install netcat
while ! nc -vz localhost 4444; do sleep 1; done
@xymor
xymor / grails-ignore
Created March 8, 2012 22:26
Set a single svn ignore list in all grails projects recursively
#forgive my newb bash skillz
find . -iname grails-app | xargs -I {} readlink -f {} | xargs -I {} dirname {} | xargs -I {} svn propset svn:ignore "$(echo -e "*.iml\n*.ipr\n*.iws\n*.launch\n*.prefs\n*.tmproj\n*Db.log\n*Db.properties\n*Db.script\n.classpath\n.hg\n.hgignore\n.idea\n.project\n.settings\nRuleLogFile.log\nbin\nbin-groovy\ndevDB.*\ndevDb.*\nout\nplugin.xml\nprodDb.*\npromotional.log\nstacktrace.log\ntarget\ntarget-eclipse\ntest-output\ntestDb.*\n")" {}
@xymor
xymor / gvm
Created January 17, 2012 18:29
simple grails installer and env switcher
#inspired by rvm, npm, etc
# gvm 2.0.0
gvm () {
export PATH=~/.grails/grails-dists/grails-$1/bin:$PATH
export GRAILS_HOME=~/.grails/grails-dists/grails-$1
if [ -d "grails-app" ]; then
grails clean
fi
}