Skip to content

Instantly share code, notes, and snippets.

View pangkalizer's full-sized avatar

Allan Andal pangkalizer

  • Sydney, Australia
View GitHub Profile
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
@pangkalizer
pangkalizer / .powrc
Created September 10, 2013 00:56
powrc
if [ -f "$rvm_path/scripts/rvm" ]; then
source "$rvm_path/scripts/rvm"
if [ -f ".rvmrc" ]; then
source ".rvmrc"
fi
if [ -f ".ruby-version" ]; then
rvm use `cat .ruby-version`
fi
after "deploy:restart", "resque:stop_workers"
namespace :resque do
task :stop_workers, :except => { :no_release => true } do
run "cd #{current_path} && rake RAILS_ENV=#{rails_env} resque:stop_workers"
end
end
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
def to_geos(coordinates)
f = RGeo::Geos.factory
points = coordinates.map {|p| p.map {|i| f.point(i.first, i.last)} }
rings = points.map {|p| f.linear_ring(p) }
polygons = rings.map {|r| f.polygon(r) }
multi_polygons = f.multi_polygon(polygons)
end

Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.

So instead of this:

require 'carrierwave/processing/mini_magick'

@pangkalizer
pangkalizer / mysql
Created May 31, 2013 04:23
mysql inspect
mysqld --verbose --help
# first sphinx
brew install sphinx
# the formula does not install libsphinxclient :/
wget http://sphinxsearch.com/files/sphinx-2.0.4-release.tar.gz
tar xzf sphinx-2.0.4-release.tar.gz
cd sphinx-2.0.4-release/api/libsphinxclient/
CXXCPP="gcc -E" ./configure --prefix=/usr/local
make
make install
rvm pkg install libyaml
rvm install 1.9.3
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
git clone https://github.com/SublimeLinter/SublimeLinter.git
git clone git://github.com/kemayo/sublime-text-2-git.git Git
https://github.com/n00ge/sublime-text-haml-sass