Skip to content

Instantly share code, notes, and snippets.

View derencius's full-sized avatar
🍀
Wish me luck, I'm fixing my bugs

Marcus Derencius derencius

🍀
Wish me luck, I'm fixing my bugs
View GitHub Profile
@derencius
derencius / find_gap.sql
Created August 24, 2011 19:42
sql to find largest serial column leaps in a table.
-- 1) ran fine for 2 mi records table.
-- 2) assuming the table name is clients.
select did, cid, did - cid as gap
from
(
select
d.id as did,
(select min(id) as cid from clients c where c.id > d.id ) as cid
from
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5666.3~123/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
@derencius
derencius / portuguese_dict.sql
Created June 8, 2011 06:23
Unaccented PostgreSQL - 9.0.4
CREATE TEXT SEARCH CONFIGURATION unaccented_portuguese ( COPY = portuguese );
ALTER TEXT SEARCH CONFIGURATION unaccented_portuguese
ALTER MAPPING FOR hword, hword_part, word
WITH unaccent, portuguese_stem;
@derencius
derencius / bank.rb
Created May 27, 2011 17:03
Studies
class Base
def self.get(code, nsa)
klass = case code
when '341' then Itau
when '071' then Brb
else
raise NotImplementedError
end
return klass.new (nsa)
end
@derencius
derencius / unaccent.sql
Created May 26, 2011 01:31
Unaccent PostgreSQL 8.4
-- Adjust this setting to control where the objects get created.
SET search_path = public;
-- Standalone 'unaccent' function
CREATE OR REPLACE FUNCTION unaccent (text) RETURNS text
AS '/usr/lib64/pgsql/unaccent'
LANGUAGE C IMMUTABLE STRICT;
-- New 'unaccentdict' dictionary for text search indexer
diff --git a/unactest1.c b/unactest1.c
index 519691d..00aafbf 100644
--- a/unactest1.c
+++ b/unactest1.c
@@ -26,415 +26,9 @@
#include "unac.h"
-static char* longstr_expected = "
+static char* longstr_expected = "";
diff --git a/unactest1.c b/unactest1.c
index 519691d..00aafbf 100644
--- a/unactest1.c
+++ b/unactest1.c
@@ -26,415 +26,9 @@
#include "unac.h"
-static char* longstr_expected = "
+static char* longstr_expected = "";
@derencius
derencius / client.rb
Created April 10, 2011 04:22
Using model's sequence next value before inserting for special manipulation.
# id : serial
# check_digit : integer
class Client
set_primary_key :id
before_create :define_check_digit
private
@derencius
derencius / xcode.rb
Created March 10, 2011 03:05
Download Xcode using wget. Useful for slow or intermittent connections. it uses wget and mechanize.
require 'rubygems'
require 'mechanize'
if ARGV.size < 3
puts %q{Usage: ruby xcode.rb USERNAME PASSWORD "DOWNLOAD_URL" [WGET_PARAMS]}
puts %q{Example: ruby xcode.rb [email protected] 123456 "https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/xcode_4_and_ios_sdk_4.3__final/xcode_4_and_ios_sdk_4.3__final.dmg" }
exit
end
a = Mechanize.new { |agent|
@derencius
derencius / utf8_header.rb
Created February 3, 2011 19:05 — forked from francesc/utf8encode.rake
thor file to add utf-8 header on ruby files. useful for converting ruby 1.8 projects to 1.9
class Utf8Header < Thor
desc "add", "Add Content UTF-8 on top of all .rb/.feature files"
# copy & pasted from https://gist.github.com/738245
def add
files = Array.new
["*.rb", "*.rake","*.feature"].each do |extension|
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ])
end
files.each do |file|