This file contains 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/local/bin/ruby | |
require 'rubygems' | |
gem 'passenger' | |
require 'phusion_passenger' | |
require 'phusion_passenger/platform_info' | |
require 'phusion_passenger/admin_tools/memory_stats' | |
require 'optparse' | |
include PhusionPassenger |
This file contains 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
$ sudo puppet apply --verbose manifests/site.pp | |
/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead. | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot load such file -- puppet/provider/confine/operatingsystem | |
Could not load confine test 'operatingsystem': cannot |
This file contains 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
$ vagrant init lucid64 | |
A `Vagrantfile` has been placed in this directory. You are now | |
ready to `vagrant up` your first virtual environment! Please read | |
the comments in the Vagrantfile as well as documentation on | |
`vagrantup.com` for more information on using Vagrant. | |
bogle> $ vagrant up | |
[default] Importing base box 'lucid64'... | |
[default] The guest additions on this VM do not match the install version of | |
VirtualBox! This may cause things such as forwarded ports, shared | |
folders, and more to not work properly. If any of those things fail on |
This file contains 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
# From charlest here: | |
# http://www.vanityfair.com/online/daily/2012/07/microsoft-downfall-emails-steve-ballmer | |
Taking platform developers and throwing them against hard goals and deadlines kills your ability to adapt. Management | |
and project stakeholders end up making too many decisions about the technology away from the people who know it | |
best – the people building it. To show progress and keep management happy, engineers shift their focus to tangible | |
deliverables and ignore the pieces management can't understand, like the underlying architecture. You start going | |
down the path of building lots of bells and whistles, but nothing solid that you can competitively leverage. |
This file contains 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
# Use Kernel#tap | |
# wrong | |
x = [1,2] | |
x << 3 | |
return x | |
# right | |
[1,2].tap {|y| y << 3 } |
This file contains 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
irb(main):014:0> puts RUBY_VERSION ; n = 5000 ; Benchmark.bm {|x| x.report { n.times {' '.strip.empty?} } ; x.report { n.times { ' ' =~ /^\s*$/ } } } | |
2.1.5 | |
user system total real | |
0.010000 0.000000 0.010000 ( 0.007651) | |
0.000000 0.010000 0.010000 ( 0.005907) | |
irb(main):016:0> puts RUBY_VERSION ; n = 5000 ; Benchmark.bm {|x| x.report { n.times {' '.strip.empty?} } ; x.report { n.times { ' ' =~ /^\s*$/ } } } | |
2.2.0 | |
user system total real | |
0.000000 0.000000 0.000000 ( 0.001773) |
This file contains 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
Synvert::Rewriter.new 'rails', 'redirect_with_notice' do | |
description <<-EOS | |
Combines flash setting and redirect to. | |
flash[:notice] = "huzzah" | |
redirect_to root_path | |
=> | |
redirect_to root_path, notice: "huzzah" | |
EOS | |
within_file 'app/controllers/**/*rb' do | |
within_node type: 'def' do |
This file contains 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
a = {zzz: [{b: 1, c: 2}, {b:3, c:4}]} | |
# slight variant on https://stackoverflow.com/questions/10676608/ruby-deleting-all-instances-of-a-particular-key-from-hash-of-hashes | |
class Hash | |
def deep_reject_key!(key) | |
keys.each {|k| delete(k) if k == key || self[k] == self[key] } | |
values.each do |v| | |
v.deep_reject_key!(key) if v.is_a? Hash | |
v.each {|i| i.deep_reject_key!(key) if i.is_a? Hash } if v.is_a? Array |
This file contains 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 Arel | |
module Visitors | |
class MyWhereSsqlWithoutSql < Arel::Visitors::ToSql | |
def initialize(inner_visitor, *args, &block) | |
@inner_visitor = inner_visitor | |
super(*args, &block) | |
end | |
private |
This file contains 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
class TravelOption < ApplicationRecord | |
has_many :travels | |
end | |
class Travel < ApplicationRecord | |
belongs_to :travel_option | |
end | |
>> TravelOption.joins(:travels).where(location_id: 1).select(:location_id, :price, :tour_id).map(&:tour_id) |
OlderNewer