Skip to content

Instantly share code, notes, and snippets.

View pangkalizer's full-sized avatar

Allan Andal pangkalizer

  • Sydney, Australia
View GitHub Profile
#!/bin/bash
#
# god Startup script for god (http://god.rubyforge.org)
#
# chkconfig: - 85 15
# description: God is an easy to configure, easy to extend monitoring \
# framework written in Ruby.
#
CONF_DIR=/etc/god

Using DViz.js with ActiveAdmin (Rails)

At https://BringBee.ch we have an internal ActiveAdmin App that we use to keep tabs on the recent activity. It's dashboard could do with some pretty graphs showing the stats of orders processed each week.

Today I ran across https://github.com/akngs/dviz so I decided to give it a spin. What follows is not by any means best practice but it got the results I wanted. The steps were pretty simple:

Get the source

in your vendor/assets/javascripts:

We couldn’t find that file to show.
changeViewportMeta = function() {
$('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=1, maximum-scale=1.3, width=device-width');
if ($(window).width() <= 320) {
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.63, maximum-scale=1.3, width=480');
} else if ($(window).width() <= 480) {
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.89, maximum-scale=1.3, width=480');
} else if ($(window).width() <= 768) {
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.8, maximum-scale=1.3, width=920');
} else if ($(window).width() <= 1024) {
return $('meta[name=viewport]').attr('content', 'user-scalable=yes, initial-scale=0.85, maximum-scale=1.3, width=920');
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"
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/

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'

# 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
class UsersController < ApplicationController
respond_to :html, :json
def index
@json = User.all.to_gmaps4rails
respond_with @json
end
end