Skip to content

Instantly share code, notes, and snippets.

View salgadobreno's full-sized avatar

Breno Santos Salgado salgadobreno

  • Origem Motos
  • Brasília, Brazil
View GitHub Profile
-- there's 5 events in the range 2010-10-15 to 2010-10-21
-- event1,event2,event3 and event4 have start_at in 2010-10-20
-- and event5 is on 2010-10-21
-- thats their tags: event1{tag1,tag2,tag3,tag4}, event2{tag1,tag2,tag3}, event3{tag1,tag2}, event4{tag1}
-- and event5 has only 'tag4'... so..
-- the tag count in the range 2010-10-15 to 2010-10-21 should display count = 2 for tag4...but its ignoring
-- the 2010-10-21 day, what is wrong with this select?
-- event with id = 13 is the one with tag4 with the start_at thats being ignored(2010-10-21)
sqlite> select events.* from events where events.id = 13;
#e is the Event.first
#I just can't understand whats going on...
#first date is Sat, 01 Jan
#after saving it becomes Sun, 31 Dec
#after re-retrieving the same record its Fri, 31 Dec
#WHATS GOING ON HERE?!
irb(main):088:0> date = Date.civil(01,01,01)
=> Sat, 01 Jan 0001
irb(main):090:0> e.start_at = date
<%= form_for [:event, new_comment] do |f| %>
<%= f.text_area :comment %>
<%= f.submit "Comentar" %>
<% end %>
@salgadobreno
salgadobreno / wtf-linkedin.rb
Created June 2, 2011 20:47
One day I thought I'd save that linkedin business segments list so I could exercise business options but I saved the whole html node instead.. then I saw that it were OVER 9000(!) characters in just one line so I did a .rb to get what I wanted...(wtf)
mi = <<HEHE
<select name="industryChooser" id="industryChooser-lookingProfileForm"><option value="" selected="">-</option><option value="47" class="corp fin">Accounting</option><option value="94" class="man tech tran">Airlines/Aviation</option><option value="120" class="leg org">Alternative Dispute Resolution</option><option value="125" class="hlth">Alternative Medicine</option><option value="127" class="art med">Animation</option><option value="19" class="good">Apparel &amp; Fashion</option><option value="50" class="cons">Architecture &amp; Planning</option><option value="111" class="art med rec">Arts and Crafts</option><option value="53" class="man">Automotive</option><option value="52" class="gov man">Aviation &amp; Aerospace</option><option value="41" class="fin">Banking</option><option value="12" class="gov hlth tech">Biotechnology</option><option value="36" class="med rec">Broadcast Media</option><option value="49" class="cons">Building Materials</option><option value="138" class="corp man">Business Su
@salgadobreno
salgadobreno / redis.conf
Created July 25, 2011 21:46
Redis.conf file(copied from some other gist), with virtual memory options commented out(vm is deprecated -> http://redis.io/topics/virtual-memory)
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@salgadobreno
salgadobreno / redis-server
Created July 25, 2011 21:56
redis-server file
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@salgadobreno
salgadobreno / gist:3129217
Created July 17, 2012 12:46
Compile ruby 1.9.3 from source
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
tar -xvzf ruby-1.9.3-p194.tar.gz
cd ruby-1.9.3-p194/
./configure --prefix=/usr/local
make
sudo make install
sudo gem install bundler --no-ri --no-rdoc
echo "Done."
# dropbox service
DROPBOX_USERS="user1"
start() {
echo "Starting dropbox..."
for dbuser in $DROPBOX_USERS; do
start-stop-daemon -b -o -c $dbuser -S -x /home/$dbuser/.dropbox-dist/dropboxd
done
}
stop() {
@salgadobreno
salgadobreno / pizzapicker.rb
Created October 22, 2012 13:27
I hate spending 20 minutes trying to pick through a big menu, pizza flavor picker
pizzas = ["3 PODERES","CALABRESA EPECIAL","CAMARÃO AO ALHO PORÃ","CATUMARÃO","CHARGE","CHOCOLATE COM BANANA","CHOCOLATE COM MORANGO","FRANGO XADREZ","LINGUIÃA BEBADA","LINGUIÃA MINEIRA","MARCUS ANTONIUS","MARGUERITA DO CHEFF","NERO","PATRICIUS","PEPPERONI ESPECIAL","PRESTÃGIO","ROAST BEEF","ROMEU E JULIETA","SONHO DE VALSA","VEGETARIANA","ABACAXI","ABACAXI DO CHEFF","ADRIÃTICA","ALHO E ÃLEO","ALICHE","ATUM","AVE CESAR","BACON","BANANA","BRASILIENSE","BRUTUS","CALABRESA","CALIFÃRNIA","CALÃGULA","CAMARÃO","CESAR","CHESTER","CINCO QUEIJOS","CLAÃDIA","CLEÃPATRA","COLISEU","ESCAROLA","ESCAROLA DO CHEFF","ESPÃRTACO","FRANGO","CATUPIRY","IBÃRICA","JÃLIOS","LAMPIÃO & MARIA BONITA","LOMBO CANADENSE","MARGUERITA","MEDITERRÃNEA","MILHO","MUSSARELA","NAPOLITANA","OTÃVIO AUGUSTO","PALMITO","PAULISTA","PEITO DE PERU","POMPEIUS","PORTUGUESA","PRESUNTO","QUATRO QUEJOS","ROMA","TIBÃRIUS","TITUS FLAVIUS"]
pizzas.sample 2
@salgadobreno
salgadobreno / markdown-tag.rb
Last active December 10, 2015 21:48 — forked from tmtk75/markdown-tag.rb
Markdown Tag for Jekyll
=begin
Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid.
Usage:
{% markdown <filename> %}
Dependency:
- kramdown
=end
module Jekyll
class MarkdownTag < Liquid::Tag
def initialize(tag_name, text, tokens)