This file contains hidden or 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 "https://rubygems.org" | |
# Declare your gem's dependencies in breakout_elasticsearch.gemspec. | |
# Bundler will treat runtime dependencies like base dependencies, and | |
# development dependencies will be added by default to the :development group. | |
gemspec | |
# jquery-rails is used by the dummy application | |
gem "jquery-rails" |
This file contains hidden or 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
module QueryTracer | |
# Borrowed some ANSI color sequences from elsewere | |
CLEAR = ActiveSupport::LogSubscriber::CLEAR | |
BOLD = ActiveSupport::LogSubscriber::BOLD | |
def self.start! | |
# Tap into notifications framework. Subscribe to sql.active_record messages | |
ActiveSupport::Notifications.subscribe('sql.active_record') do |*args| | |
QueryTracer.publish(*args) |
This file contains hidden or 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
def table_info(model) | |
puts "# Table name: #{model.table_name}", "#", "# Columns:" | |
cols = model.columns.inject([]) {|arr, e| arr << [e.name || '-', e.type || '-', e.sql_type || '-', e.limit || '-', e.default || '-'].map(&:to_s)} | |
col_sizes = cols.inject([]) {|arr, c| arr << c.map {|e| e.size }} | |
max_sizes = 4.times.inject([]) {|arr, i| arr << col_sizes.max_by {|e| e[i] }[i] } | |
cols.each { |c| puts "# #{c[0].ljust(max_sizes[0] + 2)}:#{c[1].ljust(max_sizes[1] + 3)}#{c[2].ljust(max_sizes[2] + 2)}#{c[3].ljust(max_sizes[3] + 2)}#{c[4]}" } | |
puts "#", "# Indexes:" | |
indexes = ActiveRecord::Base.connection.indexes(model.table_name).map {|e| [e.name, "(#{e.columns.join(", ")})"]} |
This file contains hidden or 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
require 'digest/sha2' | |
# Usage: ruby jenkins-log-parser.rb jenkins-output.txt | |
# ps.: run chamod +x on this file | |
log_file = $*.shift | |
class Digester | |
@digester = Digest::SHA256.new | |
def self.digest(msg) |
This file contains hidden or 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/ruby | |
# searches inside your whole skype history for a specific term | |
# usage: skype-search term | |
# don't forget to add inside any /bin directory (like /usr/bin or ~/bin) and do chmod +x skype-search | |
SKYPE_DB_PATH = "/Users/leandro/Library/Application Support/Skype/leandroico/main.db" | |
puts `sqlite3 -line '#{SKYPE_DB_PATH}' "SELECT author, from_dispname, datetime(timestamp, 'unixepoch') as date, body_xml FROM Messages where body_xml LIKE '%#{$*.shift}%' ORDER BY timestamp;"` |
This file contains hidden or 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 /Users/leandro/.vim/gist.vim | |
source /Users/leandro/.vim/plugin/matchit.vim | |
filetype indent on " Automatically detect file types. | |
set nocompatible " We don't want vi compatibility. | |
" Add recently accessed projects menu (project plugin) | |
set viminfo^=! | |
set ts=2 sw=2 et |
This file contains hidden or 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
(function($) { | |
$.extend($.expr[':'], { | |
inline: function(a) { | |
return $(a).css('display') == 'inline'; | |
}, | |
block: function(a) { | |
return $(a).css('display') == 'block'; | |
} | |
}); | |
})(jQuery); |
This file contains hidden or 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
var body = document.body; | |
if (body.requestFullScreen) { | |
body.requestFullScreen(); | |
} else if (body.mozRequestFullScreen) { | |
body.mozRequestFullScreen(); | |
} else if (body.webkitRequestFullScreen) { | |
body.webkitRequestFullScreen(); | |
} |
This file contains hidden or 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
var gCoords = new google.maps.LatLng(-16.698395,-49.26394) | |
, gmapData = { | |
center: gCoords, | |
zoom: 16, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
scrollwheel: false | |
} | |
, gMap = new google.maps.Map($('#google-map-localizacao').get(0), gmapData) | |
, gMarker = new google.maps.Marker({ | |
position: gCoords, |
This file contains hidden or 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
log_format complete '[$time_local] REQ_TIME:$request_time UPS_TIME:$upstream_response_time C:$remote_addr H:$host ' | |
'URI:$request_uri ($request_method) ST:$status SZ:$bytes_sent ' | |
'REFERER:http_referer AGENT:$http_user_agent'; |