Skip to content

Instantly share code, notes, and snippets.

@filipechagas
filipechagas / gist:11300399
Created April 25, 2014 19:30
Generate self signed ssl keys, for test purpose
openssl req -new -x509 -nodes -out server.crt -keyout server.key
@filipechagas
filipechagas / gist:95d1bf25dbc7a39aefb9
Created May 19, 2014 20:28
Use vim to search and replace from command line
### Perform a search and replace from the commandline
$ vim -c '%s`search`replace`g' -c 'wq' *.html
@filipechagas
filipechagas / gist:7989c2e4b6c1a5f0aa90
Created May 21, 2014 00:11
Install latest git on debian based distros
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
@filipechagas
filipechagas / gist:29f740a7adf8b6cae710
Created May 29, 2014 13:27
Postgres - FTS - pg_search - solution to problem with slow rank or weighted search on multiple columns
class AddIndexForFullTextSearch < ActiveRecord::Migration
def up
execute "ALTER TABLE users ADD COLUMN tsv tsvector"
execute <<-QUERY
UPDATE users SET tsv = (to_tsvector('english', coalesce("building"."first_name"::text, '')) ||
to_tsvector('english', coalesce("building"."last_name"::text, '')));
QUERY
execute "CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
ON users FOR EACH ROW EXECUTE PROCEDURE
@filipechagas
filipechagas / gist:081995926cc0218ee735
Created June 2, 2014 01:00
Postgres - Fuzzy Match
CREATE EXTENSION fuzzystrmatch;
select dmetaphone('filipe'), dmetaphone('phillip'), dmetaphone('felipe');
localtest.me
vcap.me
lvh.me
@filipechagas
filipechagas / gist:96bc3d5f0ad3956f51e6
Created June 3, 2014 18:42
Osx - Homebrew - Install Sphinx
brew install sphinx --mysql
@filipechagas
filipechagas / gist:ea14bc7dcd65ef6bd79c
Created June 8, 2014 20:25
Cancelar SMSs publicitários
Fonte: http://olhardigital.uol.com.br/noticia/aprenda-a-combater-o-spam-que-chega-por-sms/42460
Como explica a equipe da PSafe, é possível combater esse problema de duas formas. A primeira é solicitando à operadora que bloqueie o envio de ofertas por sms, basta enviar SAIR para 888 (Claro), 55555 (Oi), 4112 (Tim) ou 457 (Vivo).
Além disso, sempre que topar com uma mensagem indesejada, o consumidor pode colocar o número na lista negra da Anatel encaminhando o que foi recebido para 7726.
@filipechagas
filipechagas / gist:eae4f633b864287f68c0
Created August 22, 2014 19:48
Postgres Rails - UTF-8 Problem
source: http://stackoverflow.com/questions/13115692/encoding-utf8-does-not-match-locale-en-us-the-chosen-lc-ctype-setting-requires
I am answering this because nothing from StackOverFlow worked for me.
I combined two solutions from other sites that did the job (this answer works for Ubuntu server 12.04 and PGSQL 9.1):
Create a file:
nano /etc/profile.d/lang.sh
Add the following
# username = "my_username"
# pwd = "my_password"
# target_path = "my_target_path"
# saving auth cookie
system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \
https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027}
(25..600).each do |i|