This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Source: http://archives.postgresql.org/pgsql-sql/2005-08/msg00046.php | |
-- Thanks: http://archives.postgresql.org/pgsql-es-ayuda/2008-02/msg00293.php | |
CREATE FUNCTION count_estimate(query text) RETURNS integer AS $$ | |
DECLARE | |
rec record; | |
rows integer; | |
BEGIN | |
FOR rec IN EXECUTE 'EXPLAIN ' || query LOOP | |
rows := substring(rec."QUERY PLAN" FROM ' rows=([[:digit:]]+)'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :set_charset, :set_locale | |
# Setea el charset con el que vamos a hablar con el | |
# cliente | |
def set_charset | |
content_type = headers["Content-Type"] || "text/html" | |
if /^text\//.match(content_type) | |
headers["Content-Type"] = "#{content_type}; charset=utf-8" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BestDescribeRecord | |
module ActiveRecord | |
# Best Describe! | |
class Base | |
# Definición de cómo describir al registro | |
# Si no se ha especificado el "best_describe", | |
# entones el plugin intentará descubrir cómo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculo del coeficiente K | |
# | |
# Ejemplo de uso: | |
# | |
# Si la cantidad de partidas es menor a 15 => k = 25 | |
# Si el elo es menor a 1400 => k = 25 | |
# Si el elo es menor a 2000 => k = 20 | |
# De otra forma, k = 15 | |
# EloCalculator.set_kfactor_rule :games => true, :lt => 15, :k => 25 | |
# EloCalculator.set_kfactor_rule :elo => true, :lt => 1400, :k => 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'mkmf' | |
# Seteamos el nombre de la extensión | |
extension_name = 'natcmp' | |
# Directorio de trabajo | |
dir_config(extension_name) | |
# Esta es la verdadera acción que crea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* Libreria para listas de proposito general | |
* Haga lo que quiera con ella, pero no hay garantias | |
* Silvio Quadri (c) 2009 | |
* Buenos Aires, Argentina | |
* | |
* */ | |
#include "list.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR=../../it/css | |
for cssfile in $DIR/*.css; do | |
echo $cssfile ../css/`basename $cssfile` | |
cat $cssfile | ruby redize.rb 45 > ../css/`basename $cssfile` | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use LWP; | |
use Mojo::DOM; | |
my $start = @ARGV[0]; | |
my $end = @ARGV[1] || 100; | |
while( $start <= $end ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# | |
# Global vars | |
SERVNAME=example | |
PIDFILE=/tmp/$SERVNAME.pid | |
COMMAND=/path/to/binary.sh | |
USER=root | |
# Get function from functions library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __GNUC__ | |
#include <stdint.h> | |
static int32_t wordval; | |
static int32_t start_neg_pow2 ; | |
uint16_t lookKbits(uint8_t k) | |
{ | |
__asm__("movb %0,%%dl" : : "g"(k) ); | |
__asm__("movb 6,%cl"); |
OlderNewer