Skip to content

Instantly share code, notes, and snippets.

View oshanz's full-sized avatar
On vacation

Oshan Wisumperuma oshanz

On vacation
View GitHub Profile
oshanz / Contract Killer
Created March 26, 2021 08:57 — forked from malarkey/Contract Killer
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

That’s not a great thing to have to say, is it? However, I bet you’ve said it before and may not have immediately know why.

With liberal use of puts and maybe pry, you can figure out what a problem might be next time you run it, but sometimes you need to figure out what that problem is right now.

As it turns out, and I know this is a shocker, Ruby processes are just regular processes. They can be debugged with gdb.

Having recently had the need to find out why a job of mine was running particularly slowly, I found out about this lovely tool the hard way: frantic googling. I found some very useful functions for gdb in a blog post by Rasmus on Ruby callstacks.

oshanz / database.yml
Created March 2, 2020 18:55 — forked from henrik/database.yml
Per-branch development database with Git and Ruby on Rails.
DEFAULT_DB = 'myapp_development'
DB_BRANCHES = %w[ t79 ]
branch = `git symbolic-ref HEAD 2> /dev/null`.chomp.split('/').last
dev_db = DB_BRANCHES.include?(branch) ? branch.gsub(/[^a-zA-Z0-9_]/, '') : DEFAULT_DB
puts "Using dev database: #{dev_db.inspect}"
database: <%= dev_db %>
oshanz / High performance tuning of Nginx
Created January 13, 2020 12:51 — forked from perusio/gist:2154235
High performance tuning of Nginx
## From a post on the ML, apropos this:
## For sysctl.conf
net.ipv4.tcp_slow_start_after_idle = 0
echo "2048 64512" > /proc/sys/net/ipv4/ip_local_port_range
echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle
echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse
oshanz / delayed_job@.service
Created January 6, 2020 12:59 — forked from stevensona/delayed_job@.service
systemd unit file for running ruby/rails delayed_job as service
# Keep delayed job workers running using systemd on ubuntu
# Usage
# Start "sudo systemctl start delayed_job@{0..3}" to start 4 worker instances
# Enable "sudo systemctl enable delayed_job@{0..3}" to enable 4 worker instances
# Restart "sudo systemctl restart delayed_job@{0..3}" to restart 4 worker instances
# Disable "sudo systemctl disable delayed_job@{0..3}" to disable 4 worker instances
# Stop "sudo systemctl stop delayed_job@{0..3}" to stop 4 worker instances
Description=Delayed Job Worker %i
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
oshanz / Serializor.php
Created October 16, 2015 09:07 — forked from bubba-h57/Serializor.php
Doctrine 2 Entities Serialized to JSON
namespace H57\Util;
class Serializor {
* Converts the Doctrine Entity into a JSON Representation
* @param object $object The Object (Typically a Doctrine Entity) to convert to an array
oshanz / date.sql
Last active August 29, 2015 14:27 — forked from johngrimes/date.sql
MySQL Date Dimension Build Script
/* Adapted from Tom Cunningham's 'Data Warehousing with MySql' ( */
###### small-numbers table
DROP TABLE IF EXISTS numbers_small;
CREATE TABLE numbers_small (number INT);
INSERT INTO numbers_small VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
###### main numbers table
CREATE TABLE numbers (number BIGINT);