I am only one, but I am one. I cannot do everything, but I can do something. And because I cannot do everything, I will not refuse to do the something that I can do.
Edward Hale

oozey mess
YOU ARE THE REASON

blake kathryn

tannertan36
we're not kids anymore.

@theartofmadeline
Today's Document
Jules of Nature
he wasn't even looking at me and he found me
RMH

pixel skylines
Sweet Seals For You, Always

Origami Around
Mike Driver
One Nice Bug Per Day

Kaledo Art

titsay
KIROKAZE

No title available
let's talk about Bridgerton tea, my ask is open
seen from Germany

seen from United States

seen from Malaysia

seen from Russia

seen from France
seen from United States

seen from Brazil
seen from Romania

seen from Canada

seen from Netherlands

seen from Canada

seen from United States
seen from Malaysia

seen from Malaysia
seen from Indonesia

seen from Türkiye

seen from Türkiye

seen from Thailand

seen from United States

seen from Brazil
@edgar
I am only one, but I am one. I cannot do everything, but I can do something. And because I cannot do everything, I will not refuse to do the something that I can do.
Edward Hale
An easy way to debug gems based on Ruby’s net::http
BEGIN { require 'net/http' Net::HTTP.module_eval do alias_method '__initialize__', 'initialize' def initialize(*args,&block) __initialize__(*args, &block) ensure @debug_output = $stderr ### if ENV['HTTP_DEBUG'] end end }
(via: https://gist.github.com/ahoward/736721)
How to skip all filters in controller - Rails
If you need to skip in an specific controller all the filters defined in the ApplicationController, you can do this:
class MyController < ApplicationController if Rails::VERSION::STRING > "2.3" skip_filter *_process_action_callbacks.map(&:filter) else # rails 2.3.x skip_filter filter_chain end end
If your main motivation for using containers (docker) is immutable infrastructure,then makes no sense to use them to deploy statefull systems
https://twitter.com/edgar/status/596305342054674433
Time as we (engineers) know ends on January 19, 2038 - 03:14:07 UTC
Handling single object and array in the same way in Ruby
In ruby instead of adding conditionals to know if an object is an array or not you can use Array(object) or [*object] and treat everything as an Array:
Array(1) => [1] Array([1,2]) => [1,2] Array(nil) => [] [*1] => [1] [*[1,2]] => [1,2] [*nil] => []
You break it, you own it, you fix it
Motto of a dev team
Install pg gem in Mac OS X with Postgres.app
If you’re using Postgres.app and try to install the pg ruby gem, you probably will have an error similar to this:
ERROR: Error installing pg: ERROR: Failed to build gem native extension. ... Can't find the 'libpq-fe.h header ...
The reason of the error is that you have the wrong path for --with-pg-config, so try to install the gem using this:
$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
If you have a different version of Postgres.app, juts replace 9.4 in the path aboove for the proper version number.
Rails 4.2 Server port forwarding on Vagrant
If you want to use Vagrant to develop your Rails 4.2 applications, notice that Rails 4.2 now binds to 127.0.0.1 by default and not 0.0.0.0.
So, besides the following line into your Vagrantfile:
config.vm.network "forwarded_port", guest: 3000, host: 3000
Now you need to start the server using:
$ rails server -b 0.0.0.0
The golden rule of git rebase is to never use it on public branches.
There are only two hard things in Computer Science: cache invalidation and naming things.
Phil Karlton
Elasticsearch gem for Rails 2.3
Currently our app is 8 years old and it's still based on Rails 2.3 .
Recently we're adding Elasticsearch to improve performance for some searches, but the existing Elasticsearch-Rails ruby gem requires Rails 3+.
For that reason I develop an Elasticsearch Rails gem for Rails 2.3.
The elasticsearch-rails2 library is based on the elasticsearch-model (one of the components of the elasticsearch-rails gem) and builds on top of the elasticsearch ruby library.
It aims to simplify integration of Ruby on Rails 2.3 models (ActiveRecord) with the Elasticsearch search.
Usage
require 'elasticsearch/rails2' class Article < ActiveRecord::Base include Elasticsearch::Rails2 end
Searching
response = Article.search 'fox dogs' response.took # => 3 response.results.total # => 2 response.results.first._score # => 0.02250402 response.results.first._source.title # => "Quick brown fox"
Search results
The returned response object is a rich wrapper around the JSON returned from Elasticsearch, providing access to response metadata and the actual results ("hits").
Each "hit" is wrapped in the Result class, and provides method access to its properties via Hashie::Mash.
The results object supports the Enumerable interface:
response.results.map { |r| r._source.title } # => ["Quick brown fox", "Fast black dogs"] response.results.select { |r| r.title =~ /^Q/ } # => [#{"title"=>"Quick brown fox"}}>]
In fact, the response object will delegate Enumerable methods to results:
response.any? { |r| r.title =~ /fox|dog/ } # => true
To use Array's methods (including any ActiveSupport extensions), just call to_a on the object:
response.to_a.last.title # "Fast black dogs"
For more info check the README in the github repo
Installing ruby 1.9.3 in Yosemite (Mac OS x 10.10) via RVM
I was using an old ruby 1.9.3 version (revision p392) and when I upgraded to Yosemite, I wasn't able to install ruby gems with native dependencies.
I tried to reinstall the ruby with:
rvm reinstall 1.9.3-p392 --with-gcc=clang
and
rvm reinstall 1.9.3-p392 --disable-binary --with-gcc=clang
(see source)
Even I tried removing the ruby in RVM and install it again (and also reinstall RVM from scractch) with no success.
Then I tried with the latest 1.9.3 p545 and p547 and they worked fine, so if you need to use ruby 1.9.3 in Yosemite you'll need to install a recent version (I suggest to use the latest revision), to do that use the following:
rvm install 1.9.3 --with-gcc=clang
How to create a public SSH key from the private key
Today I learned you can use the -y option in ssh-keygen command to generate a public SSH key from the private key:
ssh-keygen -f ~/.ssh/id_rsa -y > ~/.ssh/id_rsa.pub
My Pry customizations for Rails console
I'm using Pry for my Rails console, I have defined the following alias in my ~/.zshrc to start the rails console using Pry:
alias sc='./script/console --irb=pry'
The .pryrc file is analogous to the .irbrc file for IRB. You can use the .pryrc file to customize Pry.
Below is my ~/.pryrc file:
The first line configure SublimeText 3 as Pry's editor
The methods unbundled_require and load_gem allows me to load an installed gem that is not included in the current project's Gemfile. In my case I'm loading the awesome_print gem (line 45) to pretty prints Ruby objects in full color exposing their internal structure with proper indentation
And then depending on the current Rails version, I configure the Rails logger (Rails 2) or the ActiveRecord logger (Rails 3) to use the STDOUT, in order to print the SQL statements to console.
This is how it looks my Rails console with these customizations: