Skip to content

Instantly share code, notes, and snippets.

View zerobearing2's full-sized avatar

Dave Bradford zerobearing2

View GitHub Profile
@peterc
peterc / CONVENTIONS.md
Last active April 23, 2025 06:55
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
@brianhempel
brianhempel / bench_rails_memory_usage.rb
Last active March 25, 2025 18:43
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 May 9, 2025 14:00
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>