Skip to content

Instantly share code, notes, and snippets.

@hisea
hisea / VPN.md
Last active December 19, 2015 21:26
Ubuntu OpenVPN Setup

Ubuntu Official guide

Link

Ubuntu Server 14.04.1 How To setup OpenVPN server on a seperate machine than the LAN gateway (with access to other machines on server LAN)

Make sure your openvpn LAN is not the usual 192.168.1.1 or 10.0.0.1. If it is, log in to your router and change the third number ie. 192.168.(this number).1

Make sure to forward port 1194 on your router to the OpenVPN server IP

Example Network:

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 / 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.
@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}
}
# vim: ft=gitconfig
[sendemail]
multiedit = true
suppresscc = self
[color]
ui = true
[filemerge]
executable = vimdiff
[merge]
@hisea
hisea / sublime
Created July 22, 2013 20:56
ST3 user config
{
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"ensure_newline_at_eof_on_save": true,
"font_face": "Bitstream Vera Sans Mono",
"font_size": 13,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
@hisea
hisea / max_subarray_2.rb
Created May 26, 2013 00:14
Max Subarray second version
def find_max_subarray(array)
#initialize all variables to zero
max_sum = current_sum = current_start = start_idx = end_idx = cursor = 0
# Go through individual element
for cursor in 0...array.length
# current_sum is the previous sum plus current element
current_sum += array[cursor]
if current_sum > max_sum # the case where the current sum is greater than the best sum so far.
# we set best sum so far to current sum
@hisea
hisea / max_subarray.rb
Created May 23, 2013 02:03
Get the sub-array with the maximum sum
def find_max_subarray(array)
max_sum = current_sum = current_start = start_idx = end_idx = cursor = 0
while cursor < array.length
current_test = current_sum + array[cursor]
if current_test > 0
if current_sum == 0
current_start = cursor
end
current_sum += array[cursor]
# 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
@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