Skip to content

Instantly share code, notes, and snippets.

@talyric
talyric / bench_rails_memory_usage.rb
Created August 1, 2016 17:48 — forked from brianhempel/bench_rails_memory_usage.rb
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
@talyric
talyric / carrierwave.rb
Created January 22, 2016 22:48 — forked from iqbalhasnan/carrierwave.rb
carrierwave mini_magick image processing - quality, strip, exif rotation, gaussian blur, interlace
#config/initializers/carrierwave.rb
module CarrierWave
module MiniMagick
# Rotates the image based on the EXIF Orientation
def exif_rotation
manipulate! do |img|
img.auto_orient
img = yield(img) if block_given?
img
end
@talyric
talyric / CiviCRM
Created May 8, 2015 14:11
CiviCRM v4.6.2 Email Signup Embed
<script type="text/javascript">
var CRM = {"config":{"isFrontend":false}};
</script>
<script type="text/javascript" src="/wp-content/plugins/civicrm/civicrm/bower_components/jquery/dist/jquery.min.js?r=aBEHT">
</script>
<script type="text/javascript" src="/wp-content/plugins/civicrm/civicrm/bower_components/jquery-ui/jquery-ui.min.js?r=aBEHT">
</script>
<script type="text/javascript" src="/wp-content/plugins/civicrm/civicrm/bower_components/lodash-compat/lodash.min.js?r=aBEHT">
</script>
<script type="text/javascript" src="/wp-content/plugins/civicrm/civicrm/packages/jquery/plugins/jquery.mousewheel.min.js?r=aBEHT">
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2767174)
echo "Installing S3cmd..."
wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -
sudo wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list
sudo apt-get update && sudo apt-get install s3cmd
echo "Done"

Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:
@talyric
talyric / defaults.list
Last active December 29, 2016 19:29 — forked from gregd/defaults.list
[Default Applications]
x-scheme-handler/txmt=openInMine.desktop
<a href="http://www.flightline-studios.com/Music/Gone.mp3" onClick="javascript: pageTracker._trackPageview('/downloads/gone'); ">
lifecycle do
state :unverified, :default => true
state :verified,:active, :inactive, :banned
create :signup, :available_to => "Guest",
:params => [:name, :real_name, :birthday, :email_address, :password, :password_confirmation],
:become => :unverified, :new_key => true do
if self.birthday.to_time < 18.years.ago
UserMailer.deliver_email_verification(self, lifecycle.key)