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
# File: app/models/concerns/boolean_store_accessor.rb | |
# | |
# When we submit a form in order to update a model, a booelan/checkbox field is posted | |
# as '1' or '0', and if we are using ActiveRecord::Store, posted value is stored in | |
# database as '1' or '0'. By the help of this module, we store '1' and '0' | |
# values as `true` or `false`. | |
# | |
# Example usage: | |
# | |
# ``` |
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
import XMonad | |
import XMonad.Hooks.DynamicLog | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Util.Run(spawnPipe) | |
import XMonad.Config.Desktop | |
---import XMonad.Config.Gnome | |
import XMonad.Config.Xfce | |
import qualified Data.Map as M | |
import XMonad.Hooks.SetWMName | |
import XMonad.Actions.CycleWS |
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 Dashboard::Payments::CardsController < ::Dashboard::Payments::BaseController | |
self.responder = Core::CustomServiceResponder | |
respond_to :html | |
before_action :customer_required | |
def destroy | |
service = Payments::Stripe::DeleteCreditCard.new(current_user) | |
status_object = service.call(params[:identifier]) |
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
# config/initializers/action_mailer_ext.rb | |
# For Rails 2.x | |
if Rails.env.staging? | |
class ActionMailer::Base | |
def recipients(*params) | |
@recipients = "staging@example.com" | |
end | |
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 ChangeStoreSettingsToLongtext < ActiveRecord::Migration | |
def up | |
change_column :site_configs, :store_settings, :longtext | |
end | |
def down | |
change_column :site_configs, :store_settings, :text | |
end | |
end |
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 | |
# To see available batteries run "upower -e" | |
BATTERY_PERCENTAGE=`upower -i /org/freedesktop/UPower/devices/DisplayDevice |grep percentage |awk -F: '{ print $2}' |awk -F% '{gsub(/ /, ""); print $1 }' |awk -F, '{ print $1 }'` | |
if [ $((BATTERY_PERCENTAGE)) -lt 10 ]; then | |
notify-send -u critical -c device -i /usr/share/icons/gnome/48x48/status/battery-low.png "Battery Level Low!" "%$BATTERY_PERCENTAGE" | |
fi | |
# Crontab entry: |
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
Plugin 'gmarik/Vundle.vim' | |
Bundle 'L9' | |
Plugin 'tpope/vim-dispatch' | |
Plugin 'tpope/vim-commentary' | |
Plugin 'tpope/vim-bundler' | |
Plugin 'tpope/vim-rails' | |
Plugin 'vim-ruby/vim-ruby' |
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 MyModule | |
class CustomResponder < ActionController::Responder | |
include Responders::FlashResponder | |
include Responders::HttpCacheResponder | |
def has_errors? | |
case controller.action_name | |
when 'destroy' | |
resource.destroyed? ? false : true | |
else |
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
# Assumptions: | |
* Rails 3.2.x | |
* nginx | |
* capistrano deploy | |
* "X-Accel-Mapping header missing" messages in nginx error.log file | |
* You want to serve static files with nginx instead of Rails | |
# nginx configuration: |
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
" | |
" Ruby snippets | |
" Last change: August 6 2007 | |
" Version> 0.1.0 | |
" Maintainer: Eustáquio 'TaQ' Rangel | |
" License: GPL | |
" Thanks to: Andy Wokula and Antonio Terceiro for help and patches. | |
" | |
if exists("b:rubysnippets_ignore") | |
finish |
NewerOlder