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
| #!/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
| 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
| 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
| 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
| 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
| Rails.application.routes.draw do | |
| resources :fruits do | |
| mount TestEngine::Engine => '/test', as: :test_1 | |
| end | |
| resources :vegetables do | |
| mount TestEngine::Engine => '/test', as: :test_2 | |
| end | |
| end |
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/env ruby_executable_hooks | |
| # | |
| # This file was generated by RubyGems. | |
| # | |
| # The application 'compass' is installed as part of a gem, and | |
| # this file is here to facilitate running it. | |
| # | |
| require 'rubygems' |
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 run_with_timeout(cmd, limit) | |
| Open3.popen3(cmd) do |_, stdout, stderr, wait_thr| | |
| output, pid = [], wait_thr.pid | |
| begin | |
| Timeout.timeout(limit) do | |
| output = [stdout.read, stderr.read] | |
| Process.wait(pid) | |
| end | |
| rescue Errno::ECHILD | |
| rescue Timeout::Error |
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() { | |
| 'use strict'; | |
| _.mixin({ | |
| // Similar to `_.dig` but uses `window` as the starting point object. | |
| import: function(namespace, initialValue) { | |
| return _.dig(window, namespace, true, initialValue); | |
| }, | |
| // Fetch or create the nested objects referenced in @namespace@ (String or Array) |