Skip to content

Instantly share code, notes, and snippets.

View Dagnan's full-sized avatar

Michel Pigassou Dagnan

View GitHub Profile
class CommandLineApp < BasicApp
def open_url(url)
if RUBY_PLATFORM =~ /darwin/
`open #{url}`
elsif RUBY_PLATFORM =~ /linux/ && `which xdg-open` != ""
`xdg-open #{url}`
elsif RUBY_PLATFORM =~ /mswin|mingw|bccwin|wince|em/
`start #{url}`
else
puts "Please open #{@authorize_url + request_token.token} in a web browser. "
@Dagnan
Dagnan / config.log
Created August 10, 2012 13:09
Postgres formula error
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by PostgreSQL configure 9.1.4, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.4 --datadir=/usr/local/Cellar/postgresql/9.1.4/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.1.4/share/doc/postgresql --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-ossp-uuid --with-python --with-perl ARCHFLAGS='-arch x86_64'
## --------- ##
## Platform. ##
@Dagnan
Dagnan / parse_gemfile.rb
Created October 9, 2012 09:39
Gemfile parser: outputs the same Gemfile with the version of each gem used in the current project. Does not handle version of gems from a git repo.
require 'active_support/core_ext/object/try.rb'
trap("INT") { puts "Exiting..."; exit }
FILENAME = ARGV[0]
if FILENAME.nil? || FILENAME.empty?
puts 'Usage:'
puts 'ruby parse_gemfile.rb path-to-your-Gemfile'
exit
@Dagnan
Dagnan / active_model_errors.rb
Created October 24, 2012 15:14
Building an API with better errors display with JSON. Must be places in config/initializers
# -*- encoding : utf-8 -*-
ActiveModel::Errors.module_eval do
def as_json options = nil
@api_errors
end
def initialize(base)
@base = base
@messages = ActiveSupport::OrderedHash.new
@api_errors = []
@Dagnan
Dagnan / gist:9250039
Created February 27, 2014 13:32
Nokogiri and LibXML fix
gem install nokogiri -- --with-xml2-include=/opt/boxen/homebrew/Cellar/libxml2/2.9.1/includlibxml2/ --with-xml2-lib=/opt/boxen/homebrew/Cellar/libxml2/2.9.1/lib/
@Dagnan
Dagnan / gist:9bee80c203db6e2f3e4d
Created September 11, 2014 21:08
parse Gemfile
require 'active_support/core_ext/object/try.rb'
trap("INT") { puts "Exiting..."; exit }
FILENAME = ARGV[0]
if FILENAME.nil? || FILENAME.empty?
puts 'Usage:'
puts 'ruby parse_gemfile.rb path-to-your-Gemfile'
exit
@Dagnan
Dagnan / gist:de4f60bcdaa8dce08095
Last active August 29, 2015 14:06
Install Nokogiri on OSX 10.9.4
# Xcode has been installed with the full version (don't forget to accept the licence)
# Ruby has been installed with rbenv
# Not needed for recent versions of Nokogiri
#brew install libxml2 libxslt
#brew link --force libxml2 libxslt
brew tap homebrew/dupes
brew install --force libiconv
brew link --force libiconv
@Dagnan
Dagnan / gist:a81bac9c0b8e4784f93f
Created September 17, 2015 00:39
readline ruby
CONFIGURE_OPTS="--with-readline-dir=/usr/local/Cellar/readline/6.3.8/" rbenv install 2.1.5
@Dagnan
Dagnan / time.rb
Created January 4, 2017 20:23
Monkey patching Rails 3.2 to write datetimes with precision
# config/initializers/time.rb
module ActiveRecord
module ConnectionAdapters
module Quoting
alias_method :old_quoted_date, :quoted_date
alias_method :old_quote, :quote
# In Rails 3.2 quoted_date does not have the column argument
def quoted_date(value, column = nil)
# Calls original method ; default in Rails 3.2
@Dagnan
Dagnan / application.html.erb
Last active November 21, 2020 19:10 — forked from averyvery/application.rb
Inline CSS or JS in Rails 5
<!DOCTYPE html>
<html>
<head>
<%= inline_js 'application.js' %>
<%= inline_css 'application.css' %>
</head>
<body>
</body>
</html>