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
$(document).bind("ajax:before", function() {
console.log("ajax:before");
})
$(document).bind("ajax:beforeSend", function() {
console.log("ajax:beforeSend");
})
$(document).bind("ajax:success", function() {
@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)
@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
# 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 / 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."
@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 / 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 / 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
<%= form_for [:event, new_comment] do |f| %>
<%= f.text_area :comment %>
<%= f.submit "Comentar" %>
<% end %>
#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