Skip to content

Instantly share code, notes, and snippets.

View pangkalizer's full-sized avatar

Allan Andal pangkalizer

  • Sydney, Australia
View GitHub Profile
require 'resque/pool/tasks'
# this task will get called before resque:pool:setup
# preload the rails environment in the pool master
task "resque:setup" => :environment do
# generic worker setup, e.g. Hoptoad for failed jobs
end
task "resque:pool:setup" do
# Close any sockets or files in pool master
@pangkalizer
pangkalizer / proxy tunnel thru ssh
Created May 16, 2014 04:24
proxy tunnel thru ssh
ssh -C2qTnN -D 8080 username@remote_machine.com
#!/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
dd if=/dev/zero of=/root/extraswapfile bs=1M count=1024
chmod 600 /root/extraswapfile
ls -l /root/extraswapfile
mkswap /root/extraswapfile
swapon /root/extraswapfile
echo "/root/extraswapfile swap swap defaults 0 0" >> /etc/fstab
swapon -s
.map-radial-overlay {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
opacity: .7;
background-color: transparent;
background-image: -o-radial-gradient(center,circle,transparent 5%,#000 50%);

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:

# need to be run as root
# Add NewRelic repo
wget -O - https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
# sure the new repo on the list
# /etc/apt/sources.list.d/newrelic.list and set it to contain the line:
deb http://apt.newrelic.com/debian/ newrelic non-free
We couldn’t find that file to show.
@pangkalizer
pangkalizer / gist:7540998
Created November 19, 2013 06:05
stress test
# http://httpd.apache.org/docs/2.2/programs/ab.html
ab -n 1000 -c 10 [URL]
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');