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
require 'htmlentities' | |
require 'i18n/backend/active_record' | |
module I18n | |
module Backend | |
require 'i18n/core_ext/object/meta_class' | |
# Just to enhance the I18n. | |
module JustALoader | |
include Metadata |
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 TranslationHelper | |
# foo = ActionView::Base.new.extend TranslationHelper | |
# TODO: If translation is missing | |
# get a translation from google | |
# and then add it to database, marked as dirty (how?) | |
def translate(key, options = {}) | |
key = scope_key_by_partial(key) | |
options[:raise] = true | |
options[:request_locale] = options.has_key?(:locale) ? options[:locale] : I18n.locale |
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
#!/bin/bash | |
# | |
# Create all konsoles with the rails tools! | |
# | |
# Create konsole Profiles with names RailsServer, RailsConsole etc.. | |
# Set a static Title and a nice icon | |
# setTitle is not really working yet ... | |
# http://www.linuxjournal.com/node/1009239 | |
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
# ref: http://bit.ly/fN2ep8 | |
# http://twitpic.com/3rr8dk | |
def sass_colors | |
engine= Sass::Engine.new(File.read("app/stylesheets/_colors.scss"), :syntax => :scss, :load_paths => ["app/stylesheets"]) | |
environment= Sass::Environment.new | |
visitor = Sass::Tree::Visitors::Perform.new(environment) | |
engine.to_tree.children.each do | node | | |
next unless node.kind_of? Sass::Tree::VariableNode | |
visitor.send(:visit, node) |
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
gem 'responders' | |
gem 'has_scope' | |
gem 'kaminari' | |
# TODO: Find a better gem | |
gem 'csv_builder' |
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 Product < ActiveRecord::Base | |
attr_accessible :name, :category, :price, :description | |
validates_numericality_of :runtime, allow_blank: true | |
%w[author rating runtime].each do |key| | |
attr_accessible key | |
scope "has_#{key}", lambda { |value| where("properties @> (? => ?)", key, value) } | |
define_method(key) do | |
properties && properties[key] |
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
options = %w(spaghetti beaf chicken salads fruit) | |
favs = [] | |
def valid_answer(reply) | |
%w(yes no).include? reply | |
end | |
def ask question | |
reply = "" |
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
# Set the prefix to ^\ | |
unbind C-b | |
set -g prefix ` | |
bind-key ` send-prefix | |
# Set delay | |
set -sg escape-time 1 | |
set -g base-index 1 | |
setw -g pane-base-index 1 | |
bind r source-file ~/.tmux.conf \; display "Config file reloaded!" |
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
# lib/templates/active_admin/resource/admin.rb | |
ActiveAdmin.register <%= class_name %> do | |
<% attributes = Kernel.const_get(class_name).attribute_names %> | |
<% columns = Kernel.const_get(class_name).columns %> | |
<% content_columns = Kernel.const_get(class_name).content_columns %> | |
# <%= class_name %> attributes are: | |
# <%= attributes.join(" ") %> | |
# The Index Page | |
index do |i| |
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
copy handler to /usr/local/bin | |
copy desktop file to /usr/share/applications | |
sudo update-desktop-database |
OlderNewer