Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@JosephPecoraro
JosephPecoraro / shell-execution.rb
Last active September 10, 2023 10:12
Shell Execution in Ruby
# Ways to execute a shell script in Ruby
# Example Script - Joseph Pecoraro
cmd = "echo 'hi'" # Sample string that can be used
# 1. Kernel#` - commonly called backticks - `cmd`
# This is like many other languages, including bash, PHP, and Perl
# Synchronous (blocking)
# Returns the output of the shell command
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111
@dan-manges
dan-manges / passenger_status.rb
Created October 28, 2008 07:10
munin plugin for passenger
#!/usr/bin/env ruby
def output_config
puts <<-END
graph_category App
graph_title passenger status
graph_vlabel count
sessions.label sessions
max.label max processes
@rtomayko
rtomayko / Tests Is Wrong
Created January 28, 2009 20:50
Why "require 'rubygems'" In Your Library/App/Tests Is Wrong
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
@tmm1
tmm1 / em-rpc-server.rb
Created April 16, 2009 21:49
simple EM rpc server
require 'rubygems'
require 'eventmachine'
require 'socket'
module RPCServer
include EM::P::ObjectProtocol
def post_init
@obj = Hash.new
end
def receive_object method
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
1566 files, 7912 examples, 25110 expectations, 0 failures, 0 errors
IC Stats:
1: 110288 97.1255%
2: 1728 1.52177%
3: 360 0.317035%
4: 279 0.245702%
5: 109 0.0959913%
6: 117 0.103036%
7: 97 0.0854234%
8: 62 0.0546005%
require 'benchmark'
module Kernel
alias old_require require
def require(path)
#unless caller.find { |caller_line| caller_line.match /dependencies\.rb/ }
# return old_require(path)
#end
Deployment Architecture of Wholly
=================================
Front-End Webserver (NginX)
|
Load Balancer (HA Proxy)
|
|------------------------|--------------------------|
App Server1 App server2 App server3 (20 Thin Instances each)
|------------------------|--------------------------|
@eric
eric / require_tracking.rb
Created December 28, 2009 02:18
A simple tool to gather memory usage when files are required. More info at: http://bitmonkey.net/post/308322913
#
# Created by Eric Lindvall <eric@sevenscale.com>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
@actsasflinn
actsasflinn / msgpack_benchmark.rb
Created January 30, 2010 05:07
Message Pack vs similar utilities
=begin
Message Pack vs similar utilities
ruby 1.8.7 (2010-04-19 patchlevel 253) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 2010.02
Packing
user system total real
pack: bert 18.320000 0.770000 19.090000 ( 19.101583)
pack: bson_ext 0.850000 0.030000 0.880000 ( 0.878398)
pack: json_ext 2.540000 0.040000 2.580000 ( 2.582495)