Skip to content

Instantly share code, notes, and snippets.

View lucascaton's full-sized avatar

Lucas Caton lucascaton

View GitHub Profile
@lucascaton
lucascaton / itunes_match_tips.txt
Created June 10, 2012 22:10 — forked from rmhall/itunes_match_tips.txt
iTunes Match tips
My iTunes Match Track upgrading and process info:
If you have less than 25,000 tracks:
1. First let iTunes Match do its things and find all possible matches in your library and finish uploading any non-matching tracks.
2. Once its done, make a new Smart Playlist (I made a folder for all my Smart iTunes Match Related Playlists)
Name this one: iCloud-Upgradeable
Criteria:
MATCH ALL:
Bit Rate is less than 256kbps
@lucascaton
lucascaton / integration_test.rb
Created June 11, 2012 19:06 — forked from tomas-stefano/integration_test.rb
Fast Specs! Unit, model and integration tests
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'machinist/active_record'
require 'machinist/caching/active_record'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
spec_support = Rails.root.join("spec/support/**/*.rb")
@lucascaton
lucascaton / gist:2967185
Created June 21, 2012 17:31
Exemplo "feio" de ElasticSearch
class Person < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
has_many :addresses
accepts_nested_attributes_for :addresses, :allow_destroy => true
def to_indexed_json
{
:addresses => adresses.map{|p| p.name}.compact.reject(&:blank?).uniq,
class Application < ActiveRecord::Base
attr_accessible :checksum, :name, :size, :configuration_attributes
has_one :configuration, :dependent => :destroy
accepts_nested_attributes_for :configuration, :allow_destroy => :true
after_initialize :create_new_configuration
private
<%= form_for @application, :html => { :class => 'form-horizontal' } do |f| %>
<div class="control-group">
<%= f.label :name, :class => 'control-label' %>
<div class="controls">
<%= f.text_field :name, :class => 'text_field' %>
</div>
</div>
<div class="control-group">
<%= f.label :checksum, :class => 'control-label' %>
<div class="controls">
@lucascaton
lucascaton / reinstall.sh
Last active April 29, 2024 00:26 — forked from tomas-stefano/reinstall.sh
Reinstalling MySQL 5.x on macOS via Homebrew
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql
#!/usr/bin/env bash
INSTALL_DIR="${INSTALL_DIR:-/opt/local}"
VERSION=$2
YAML_VERSION="0.1.4"
APP_NAME="ruby"
URL="http://ftp.ruby-lang.org/pub/ruby/ruby-$VERSION.tar.bz2"
YAML_URL="http://pyyaml.org/download/libyaml/yaml-$YAML_VERSION.tar.gz"
PREFIX="$INSTALL_DIR/$APP_NAME/$VERSION"
YAML_PREFIX="$INSTALL_DIR/yaml"
@lucascaton
lucascaton / boot.rb
Last active December 29, 2015 14:59 — forked from lloeki/boot.rb
Monkeypatching Rails 2.3.x to boot Thin by default.
# (...)
Rails.boot!
# The code below allow to use Thin as the webserver
if $0 == 'script/server'
# commands/server.rb (#45) is not cooperative, so we patch Rack itself
require 'rack'
module Rack::Handler
class << self
@lucascaton
lucascaton / capybara_cheat_sheet.rb
Last active December 30, 2015 02:09 — forked from zhengjia/capybara cheat sheet
Capybara cheat sheet
# Navigating
visit '/projects'
visit post_comments_path(post)
# Clicking links and buttons
click_link 'id-of-link'
click_link 'Link Text'
click_button 'Save'
click 'Link Text' # Click either a link or a button
click 'Button Value'
require 'rdoc'
converter = RDoc::Markup::ToMarkdown.new
rdoc = File.read(ARGV[0] || 'README.rdoc')
puts converter.convert(rdoc)
# ruby rdoc2md.rb > README.md
# ruby rdoc2md.rb ABC.rdoc > abc.md