Skip to content

Instantly share code, notes, and snippets.

View sauron's full-sized avatar

Pablo Barrios sauron

  • San Miguel de Tucumán, Argentina
View GitHub Profile
@sauron
sauron / console_table_test.js
Created January 30, 2014 13:47
Simple example of how to use the console.table() function for data visualization.
// Use of console.table()
var iKnow = [
{ lenguage: "Ruby", level: 10 },
{ lenguage: "Go", level: 5 },
{ lenguage: ".Net", level: 8 },
{ lenguage: "FoxPro", level: 10 }
];
console.table(iKnow);
@sauron
sauron / javascript_opal_output.js
Created February 6, 2014 18:45
Output para HelloWorld de Opal.rb
/* Generated by Opal 0.5.4 */
(function($opal) {
var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice, $klass = $opal.klass, g = nil;
$opal.add_stubs(['$capitalize', '$puts', '$new', '$salute']);
(function($base, $super) {
function $Greeter(){};
var self = $Greeter = $klass($base, $super, 'Greeter', $Greeter);
var def = $Greeter._proto, $scope = $Greeter._scope;
def.name = nil;
@sauron
sauron / elasticsearch.yml.sample
Created February 13, 2014 19:57
elasticsearch.yml.sample
---
development:
:hosts:
- localhost:9200
{
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"file_exclude_patterns":
[
"*.pyc",
"*.pyo",
@sauron
sauron / hasher.rb
Created March 25, 2014 23:40
Basic hash creation methods for a given dictionary.
#Hash function which converts hash_me("leep", dictionary) => 13427273
def hash_me(text, dictionary)
h = 7
dictionary = "acdegilmnoprstuw"
text.size.times do |i|
h = (h * 37) + dictionary.index(text[i]).to_i
end
h
@sauron
sauron / http_runner.txt
Last active August 29, 2015 14:14
Easiest way to serve a static folder with ruby. Just change your working directory to the one of your app and run it with ruby.
cd /path/to/my/static/page
ruby -run -ehttpd . -p8000
@sauron
sauron / median.rb
Created June 22, 2015 17:43
Median calculation for a given Array in Ruby
def median(array)
sorted = array.sort
len = sorted.length
return (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
end
@sauron
sauron / sphinx.rb
Last active August 29, 2015 14:25
How to install sphinx 2.0.6 with Homebrew
require 'formula'
class Libstemmer < Formula
# upstream is constantly changing the tarball,
# so doing checksum verification here would require
# constant, rapid updates to this formula.
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz'
homepage 'http://snowball.tartarus.org/'
end
# ~/.gemrc
---
:benchmark: false
:verbose: true
:update_sources: true
:sources:
- http://rubygems.org/
:backtrace: false
:bulk_threshold: 1000
@sauron
sauron / test_live.html
Created April 5, 2013 01:12
Comparaciones entre live() y on()
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script>
function addClick(){
$("span.clickeable").live("click", function(){
alert("clicked");
})
};