Skip to content

Instantly share code, notes, and snippets.

View allaire's full-sized avatar

Mathieu Allaire allaire

View GitHub Profile
@allaire
allaire / test.rb
Last active August 29, 2015 14:03
# https://github.com/oortcloud/meteorite#note
$ sudo -H npm install -g meteorite
In chef?
Does not work correctly (missing root privileges):
execute 'install_meteorite' do
user 'myuser'
@allaire
allaire / monkey.rb
Last active August 29, 2015 14:05
Simple Form - Placeholders fallback on labels
# Monkeypatch placeholders to use labels as a fallback instead
module SimpleForm
module Components
module Placeholders
def placeholder_text
placeholder = options[:placeholder]
placeholder.is_a?(String) ? placeholder : (translate_from_namespace(:placeholders).present? ? translate_from_namespace(:placeholders) : translate_from_namespace(:labels))
end
end
end
export PATH="$HOME/.bin:/usr/local/bin:$PATH"
# Homebrew rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# Chefdk PATH
PATH=$HOME/.chefdk/gem/ruby/2.1.0/bin:/opt/chefdk/bin:$PATH
@allaire
allaire / Configs
Last active August 29, 2015 14:09
# in application.rb
config.i18n.load_path += Dir["#{Rails.root.to_s}/config/locales/**/*.{rb,yml}"]
-------------------------------------------------------------------------------------
# i18n-tasks finds and manages missing and unused translations https://github.com/glebm/i18n-tasks
base_locale: fr
# locales: [en, fr ]
INFO global: Vagrant version: 1.7.2
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/bin/../embedded"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_DETECTED_OS="Darwin"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"
@allaire
allaire / Mac Apps
Created March 2, 2012 04:39
Most of my Mac apps
- Adobe Suite
- Adium (Multi IM app)
- Antidote
- Aperture (Photos management/Photography)
- App Cleaner (Delete apps)
- Burn (occasional burning)
- Colloquy (IRC)
- Divvy (Window management)
- Dropbox
- Droplr
@allaire
allaire / multi_array_key_exists.php
Created August 2, 2012 00:53
multi_array_key_exists
<?php
function multi_array_key_exists($needle, $haystack)
{
foreach ($haystack as $key => $value)
{
if ($needle === $key)
{
return $key;
}
{
"auto_complete": true,
"color_scheme": "Packages/User/Tomorrow-Night-Eighties.tmTheme",
"file_exclude_patterns":
[
"*.sublime-project",
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
@allaire
allaire / validations.rb
Created October 22, 2012 23:03
Field with errors
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
unless html_tag =~ /^<label/
%{<div class="field-with-errors">#{html_tag}<label for="#{instance.send(:tag_id)}" class="message">#{instance.error_message.first}</label> </div>}.html_safe
else
%{<div class="field-with-errors">#{html_tag}</div>}.html_safe
end
end
@allaire
allaire / gist:5278796
Created March 30, 2013 23:25
Minitest setup and exemple
# Environment
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Factories
require File.expand_path('../factories', __FILE__)
# Minitest
require 'minitest/autorun'