Skip to content

Instantly share code, notes, and snippets.

View cristobal's full-sized avatar
💭
¯\_(ツ)_/¯

Cristobal Dabed cristobal

💭
¯\_(ツ)_/¯
View GitHub Profile
@cristobal
cristobal / shuffle.lua
Created March 25, 2014 22:00
Lua implementation of Fisher-Yates Shuffle "inside-out"
-- Remember to seed outside the function i.e. at top of your script
-- especially on OSX otherwise you will get the same permutations.
-- math.randomseed(os.time())
-- More info http://lua-users.org/wiki/MathLibraryTutorial
function random(min, max)
if (max == null) then
max = min
min = 0
end
public class JavaTutorial10 {
public static void main(String[] args) {
String value = "abc";
// 1. Strings are not null terminated in java
System.out.println(value.toCharArray());
System.out.println("");
@cristobal
cristobal / codeinlang.py
Created March 31, 2014 08:48
Do you want to script in some random lang, just change the langs list to your choice…
#!/usr/bin/env python
import sys
from random import shuffle
def main():
langs = ["coffe", "node", "lua", "python", "ruby", "php"]
scores = {}
for lang in langs:
scores[lang] = 0
@cristobal
cristobal / FibonacciModule.java
Created April 1, 2014 12:29
Fibonacci Module, resolving Fib in Java.
import java.lang.reflect.InvocationTargetException;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
// @see http://java67.blogspot.sg/2012/07/java-program-fibonacci-series-with.html
// @see https://github.com/raganwald/homoiconic/blob/master/2008-12-12/fibonacci.md
public class FibonacciModule {
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Properties;
@cristobal
cristobal / ruby193-installer.sh
Last active August 29, 2015 14:01 — forked from futuremill-ltd/gist:2318876
Building Ruby 1.9.3 p545 package for Debian Squeeze
#!/usr/bin/env bash
# From a fresh install of squeeze
apt-get install ruby rubygems # Need ruby to use fpm
gem1.8 install fpm --no-ri --no-rdoc
apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p545.tar.gz
tar -zxvf ruby-1.9.3-p545.tar.gz
cd ruby-1.9.3-p545
@cristobal
cristobal / jekyll_sync_publich.sh
Created May 14, 2014 12:17
Jekyll Sync Publish Cronjob
#!/usr/bin/env bash
# 0. cd into dir
dir=$(dirname $0)
cd $dir
# 1. Sync from master
git pull origin master
# 2. Get SHA's
@cristobal
cristobal / set-jboss-home.sh
Last active August 29, 2015 14:02
Bash - set JBoss Home Runtime from Brew install name or /Path/to/JBoss/installation
#!/usr/bin/env bash
##########################
# Export new jboss path #
#########################
function export_path {
# already same as exported variables(s) no changes needed
if [ ! -z "$JBOSS_HOME" ] && \
[ "$JBOSS_HOME" = "$jboss_dir" ] && \
@cristobal
cristobal / jvm.sh
Last active August 29, 2015 14:02
Change Java HOME runtime on OS X
#!/usr/bin/env bash
#
# Resources:
# - http://superuser.com/questions/490425/how-do-i-switch-between-java-7-and-java-6-on-os-x-10-8-2
#
JAVA_VMS="/Library/Java/JavaVirtualMachines"
#######################
# List available jdks #
{
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"default_font_size": 10,
"flatland_square_tabs": true,
"font_face": "PragmataPro",
"font_options":
[
"subpixel_antialias",
"no_round"
],