Skip to content

Instantly share code, notes, and snippets.

@hisea
hisea / mina_for_puma.rb
Created April 29, 2014 18:25
Puma deploy task for mina.
# Puma
# ==============================================================================
namespace :puma do
set :puma_pid, "#{app_path}/tmp/pids/puma.pid"
set :start_puma, %{
cd #{app_path}
bundle exec puma --config #{app_path}/config/puma.rb --environment #{rails_env}
}
@hisea
hisea / gist:e30c80c2c8788122f553
Last active August 29, 2015 14:25
Coding Test

Coding Test

Here is few quick Ruby and JavaScript questions for you. You can reply in-line below and/or with Gists.

1.) Can you explain Rack and some of its benefits? Have you ever written and Rack applications any if so for what purpose?

Rack is the middleware sitting between web server and Rails(or any Rack compatible Ruby framework) apps. It provides a set of standerd interfaces to the common HTTP related objects and operations. Some of the benefits of Rack:

  • Standardised interaction between web servers and ruby, making Ruby framework construction or web server's ruby capitibility implentmentation a lot easier.
  • It provides a way(Rack Middlewares) to easily implement comment low level HTTP functionality such as analytics, logging, or authentication. One example would be the gem Warden which provides Rack level authentication support.
var page = require('webpage').create(),
system = require('system'),
t, address;
if (system.args.length === 1) {
console.log('Usage: loadspeed.js <some URL>');
phantom.exit();
}
@hisea
hisea / togglable.html
Created December 30, 2010 23:09
togglable comment box
<a href="javascript:void(0)" class="toggleLink" data-mid="<%= message.id %>">Link to my partial</a>
<div id="add_comment<%=message.id%>" style="display:none">
Comment box
</div>
@hisea
hisea / git pretty log
Created December 22, 2011 05:25
.gitconfig
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
#git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
@hisea
hisea / gist:1548606
Created January 1, 2012 23:08
install node.js
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
@hisea
hisea / gist:3363163
Created August 15, 2012 20:06
Rake task with param and dependency
require 'resque/tasks'
namespace :ns do
desc "test task accepts param"
task :task, [:param] => [:environment] do |t,args|
abort "Please specify a param!" unless args[:param]
puts args[:param]
end
end
@hisea
hisea / private.xml
Created October 17, 2012 02:46
Happy Hacking Keyboard remap file for Keyremap4macbook
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>PFU</vendorname>
<vendorid>0x0853</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>HHK</productname>
@hisea
hisea / gist:5129394
Created March 10, 2013 16:53
Configure Time Zone on Ubuntu
$ date
Sun Mar 10 12:50:37 EDT 2013
$ more /etc/timezone
America/Toronto
$ sudo dpkg-reconfigure tzdata
$ sudo service cron stop
# lib/tasks/deploy.rake
namespace :deploy do
desc 'Deploy to staging environment'
task :staging do
exec 'mina deploy -f config/deploy/staging.rb'
end
end