Skip to content

Instantly share code, notes, and snippets.

View somebox's full-sized avatar
⌨️
coding nights

Jeremy Seitz somebox

⌨️
coding nights
View GitHub Profile
@somebox
somebox / osx-setup.sh
Last active December 11, 2021 13:05 — forked from foz/osx-setup.sh.md
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc
@somebox
somebox / presenters.md
Last active March 26, 2022 02:12
Thoughts About Rails Presenters

Thoughts about Rails Presenters

This is a collection of links, examples and rants about Presenters/Decorators in Rails.


The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.

Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html

@cbilson
cbilson / README.md
Last active November 18, 2022 23:19
Messing around with screen capture -> http(hls)
# Make sure you do this from time to time:
sudo apt-get update && sudo apt-get upgrade -y
# Here are the actual packages (feel free to contribute):
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev nodejs libssl-dev libreadline6-dev libreadline-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev ncurses-term automake libtool bison subversion libcurl4-openssl-dev mysql-client mysql-server postgresql postgresql-contrib imagemagick libmagickwand-dev apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev redis-server vim -y
# Make default editor vim :)
echo "export EDITOR=vim" >> ~/.bashrc
# Install RVM
@brentd
brentd / parallel_asset_compiler.rb
Created July 31, 2012 23:11
Parallelize assets:precompile
require 'parallel' # gem install parallel (https://github.com/grosser/parallel)
# Monkey patch to Sprockets::StaticCompiler, a class provided by actionpack
# that's used by the assets:precompile task. This patch uses the Parallel gem
# to parallelize asset compilation in the simplest way possible.
#
# Parallel wraps Process.fork to handle things like inter-process communication
# via pipes and determining the maximum number of processes to run based on
# your system's total logical processors. So far only tested on MRI 1.9.3 on OS X.
module Sprockets
@ksarna
ksarna / profiling_tool.rb
Created November 23, 2011 20:10
Profiling rails requests with ruby-prof
# You can use this class in your console. For example
# p = ProfilingTools.new
# p.profiled_request(:controller => :welcome, :action => :index)
# this will profile whole application stack and save file in your tmp/profiler folder
# You can also use +request+ method just to see the output for example:
#
# p.request(:controller => :offers, :action => :index)
#
# p.response.body
# p.response.cookies # and so on
@kathgironpe
kathgironpe / precompile_assets.textile
Created July 7, 2011 16:55
Rails 3.1: Precompile Assets for Cloudfront/CDN support

Naming files and using asset_path

application.scss.erb
- use <%= asset_path 'background.jpg' %>

on config/environments/production.rb

@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@mxriverlynn
mxriverlynn / 1-theproblem.js
Created June 16, 2011 01:20
solving this.model.view with underscore.js
var Credentials = Backbone.Model.extend({
// ... code for a validated event here
});
var LoginView = Backbone.View.extend({
initialize: function(){
this.loginButton = $("#login");
// tight coupling and leaky code...
this.model.view = this;
module System
extend self
def cpu_count
return Java::Java.lang.Runtime.getRuntime.availableProcessors if defined? Java::Java
return File.read('/proc/cpuinfo').scan(/^processor\s*:/).size if File.exist? '/proc/cpuinfo'
require 'win32ole'
WIN32OLE.connect("winmgmts://").ExecQuery("select * from Win32_ComputerSystem").NumberOfProcessors
rescue LoadError
Integer `sysctl -n hw.ncpu 2>/dev/null` rescue 1
end