Skip to content

Instantly share code, notes, and snippets.

View zerobearing2's full-sized avatar

Dave Bradford zerobearing2

View GitHub Profile
@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active October 6, 2022 12:47
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@nghuuphuoc
nghuuphuoc / gist:10514380
Last active August 29, 2015 13:59
Install Nexcessnet_Turpentine for Magento
1) Install Varnish first
https://gist.github.com/nghuuphuoc/7819928
2) Install Nexcessnet_Turpentine
$ cd <Magento directory>
$ chmod 755 mage
$ ./mage install connect20.magentocommerce.com/community Nexcessnet_Turpentine
Checking dependencies of packages
Starting to download Nexcessnet_Turpentine-0.6.0.tgz ...
...done: 59,467 bytes
task :console do
require 'irb'
require 'irb/completion'
require 'my_gem' # You know what to do.
ARGV.clear
IRB.start
end
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@catsby
catsby / puma.rb
Created October 17, 2013 14:28
Example config/puma.rb file
preload_app!
min_threads = Integer(ENV['MIN_THREADS'] || 0)
max_threads = Integer(ENV['MAX_THREADS'] || 5)
threads min_threads, max_threads
workers Integer(ENV['WORKER_COUNT'] || 3 )
on_worker_boot do
ActiveSupport.on_load(:active_record) do
@revans
revans / Instructions.mkd
Last active December 19, 2015 14:28
Instructions for setting up a local machine for Ruby, Rails, Sinatra, etc development.

Ruby & Rails

If you're unfamiliar or looking to get more familiar with Ruby & Rails, then checkout this tutorial and this learning site.

System Setup

Installing Homebrew will make it much easier to install the necessary libraries.

@willurd
willurd / web-servers.md
Last active July 25, 2024 14:04
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@revans
revans / osx_installer.sh
Last active October 4, 2016 05:31
OSX Installer of Homebrew, Rbenv, various homebrew libraries, rbenv plugins, gems, and ruby 1.9.3
#!/usr/bin/env bash
#
# Homebrew & Ruby setup for OSX
#
set -e
# Setup some array's
declare -a brew_libs=(apple-gcc42 openssl readline zlib libxml2 libyaml librsvg libiconv git curl solr wget redis sqlite memcached ack phantomjs mysql node)
declare -a rbenv_plugins=(ruby-build rbenv-vars rbenv-default-gems rbenv-gem-rehash)
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@revans
revans / yaml_objects.rb
Created September 24, 2012 22:08
Yockeries - Factories and Mocks from YAML
# Yockeries - Yaml + Mocks + Factories(easy way to create them)
#
# Long ago there was an uprising against YAML fixtures in the rails world. Some
# people replaced them with things like FactoryGirl, Machinist, Fabrication, and a
# bunch of others.
#
# However, YAML is still the simpliest thing that works, because it comes with
# Ruby. When you load in a yaml file with YAML.load_file, the yaml data is
# converted into a hash, which again is simple to use and test. You can take
# that hash and create a new object with it: Person.new(yaml_converted_hash),