Skip to content

Instantly share code, notes, and snippets.

@xenda
xenda / Carga Asincrona.js
Created February 8, 2009 19:44
Brings data at some intervals
function traer_nueva_data(){
$.getJSON("/data/"), function(request){
//haces algo
}
}
alvaro-pereyra-rabanals-macbook:bin alvaropereyrarabanal$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Password:
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
@xenda
xenda / .bash_profile
Created October 1, 2009 01:30
My .irbrc and .bash_profile files with some changes
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
#Etags should be based on the file parameters only (default includes INode)
FileETag MTime Size
#Rewrite stuff
RewriteEngine On
#This sets the environment variable (is_versioned) when the URL query string
#looks like ?874353948543 or any string of digits
RewriteCond %{QUERY_STRING} ^[0-9]+$
RewriteRule ^(.*)$ $1 [env=is_versioned:true]
@xenda
xenda / development.rb
Created November 19, 2009 14:26 — forked from adzap/development.rb
Restart Task and Debug with ruby-debug
# ... bottom of your development.rb
if File.exists?(File.join(RAILS_ROOT,'tmp', 'debug.txt'))
require 'ruby-debug'
Debugger.wait_connection = true
Debugger.start_remote
File.delete(File.join(RAILS_ROOT,'tmp', 'debug.txt'))
end
@xenda
xenda / Apache por Worker WPM
Created November 19, 2009 14:52
Configuración para agregar a httpd.conf
StartServers 1
ThreadsPerChild 10
MaxClients 10
MinSpareThreads 1
MaxSpareThreads 1
MaxRequestsPerChild 50000
ThreadStackSize 500000
@xenda
xenda / xenda_tinka.rb
Created November 21, 2009 16:25
Sorteando las tarjetas :)
def xenda_tinka
#los jugadores
partners = ["Angel","Alvaro","Daniel"].sort_by { rand }
#los premios
cards = %w(165 165 170)
#chocolateamos
cards = cards.sort_by { rand }
def ul_tag(collection,li_options = {},ul_options={})
list_items = collection.map{|item|
result = yield(item)
content_tag(:li,result,li_options)
}.join
content_tag(:ul,list_items,ul_options)
end
@xenda
xenda / Node Logger
Created December 13, 2009 16:20
Some test with Node.js
var sys = require('sys')
var filename = process.ARGV[2];
if (!filename)
return sys.puts("Usage: node node_logger.js filename");
var tail = process.createChildProcess("tail", ["-f", filename]);
sys.puts("listening to file " + filename);
var http = require("http");
@xenda
xenda / gist:255571
Created December 13, 2009 19:30 — forked from jsierles/gist:29838
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
# required for passenger since cron has no environment
ENV['HTTPD'] = 'httpd'
MEM_LIMIT = ARGV[0] || 500