Skip to content

Instantly share code, notes, and snippets.

On vacation

Oshan Wisumperuma oshanz

On vacation
View GitHub Profile
View futubileet.js
oshanz / date.sql
Last active Aug 29, 2015 — forked from johngrimes/date.sql
MySQL Date Dimension Build Script
View date.sql
/* 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);
oshanz / Serializor.php
Created Oct 16, 2015 — forked from bubba-h57/Serializor.php
Doctrine 2 Entities Serialized to JSON
View Serializor.php
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
View colortext.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
oshanz / delayed_job@.service
Created Jan 6, 2020 — forked from stevensona/delayed_job@.service
systemd unit file for running ruby/rails delayed_job as service
View delayed_job@.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
oshanz / High performance tuning of Nginx
Created Jan 13, 2020 — forked from perusio/gist:2154235
High performance tuning of Nginx
View 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 / database.yml
Created Mar 2, 2020 — forked from henrik/database.yml
Per-branch development database with Git and Ruby on Rails.
View database.yml
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 %>
View Using GDB to inspect a running Ruby

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.

You can’t perform that action at this time.