Skip to content

Instantly share code, notes, and snippets.


Jeremy Nicoll eltiare

View GitHub Profile
eltiare / ss
Created Oct 24, 2013
A quick and dirty server script written in Ruby
View ss
#!/usr/bin/env ruby
require 'webrick'
include WEBrick
port = ARGV[0] || 4567
puts "Starting server: http://#{Socket.gethostname}:#{port}"
server =>port,:DocumentRoot=>Dir::pwd )
trap("INT"){ server.shutdown }
eltiare / viewport-auto-scaler.js
Created Aug 16, 2013
Shameless stolen from here: This is used to account for various DPI differences in mobile devices for web pages. Put this in a script tag or a *.js file and include it in your document.
View viewport-auto-scaler.js
(function() {
var meta = document.createElement("meta");
meta.setAttribute('content', 'initial-scale=' + (1 / window.devicePixelRatio) + ',user-scalable=no');
eltiare / jquery-object-serializer.js
Last active Dec 20, 2015
An object serializer for jQuery. I don't know why this isn't already a thing...
View jquery-object-serializer.js
(function($) {
$.fn.serializeObject = function() {
var arr = this.serializeArray(), a, ret = {};
$.each(arr, function(i, a) { ret[] = a.value; });
return ret;
eltiare / copy-to-s3.rb
Created Nov 22, 2012
Multithreaded file copying to S3 via Fog and JRuby
View copy-to-s3.rb
#!/usr/bin/env jruby
# Usage:
# Save this file to /usr/local/bin/copy-to-s3.rb
# You'll want to chmod +x this file to use it on the command line (Linux/OS X: chmod +x /usr/local/bin/copy-to-s3.rb)
# If you're having trouble using JRuby, check out RVM (
# Install the fog gem: gem install fog (after running rvm use jruby, if required)
# This only works if the environment variable JRUBY_OPTS=--1.8. e.g.: export JRUBY_OPTS=--1.8 (Linux/OS X)
# You'll have to edit the options in the file at the top to match your S3 settings.
eltiare / ruby-vips crash.txt
Created Sep 10, 2012
Crash from ruby-vips
View ruby-vips crash.txt
eltiare@debian:~/apps/rballey$ rails c
Loading development environment (Rails 3.2.8)
1.9.3p194 :001 > img ='spec/fixtures/butterfly.jpg')
=> #<VIPS::JPEGReader:0x000000041154a0>
1.9.3p194 :003 > img.exif?
(irb):3: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0029 p:---- s:0103 b:0103 l:000102 d:000102 CFUNC :exif?
eltiare / brew-vips-install-fail
Created Aug 2, 2012
Fail log of brew install vips
View brew-vips-install-fail
This file has been truncated, but you can view the full file.
screamer:carrierwave-vips eltiare$ brew install vips -HEAD
==> Downloading
Already downloaded: /Library/Caches/Homebrew/vips-7.28.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/vips/7.28.0
==> make install
Making install in libvips
Making install in include
Making install in vips
glib-mkenums --template enumtemplate \
eltiare / carrierwave_config.rb
Created Jul 18, 2012
Example of a CarrierWave S3 configuration
View carrierwave_config.rb
# Here's what I have in my CarrierWave configuration file
require 'carrierwave/processing/mime_types'
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'REPLACE WITH AWS KEY', # required
:aws_secret_access_key => 'REPLACE WITH AWS SECRET' # required
eltiare / gist:3055805
Created Jul 5, 2012
vips-ruby segfault
View gist:3055805
screamer:carrierwave-vips eltiare$ rspec
(rspec:2129): GLib-CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
(rspec:2129): GLib-GObject-WARNING **: cannot retrieve class for invalid (unclassed) type `<invalid>'
/Users/eltiare/.rvm/gems/ruby-1.9.3-p194/gems/ruby-vips-0.2.0/lib/vips_ext.bundle: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
-- Control frame information -----------------------------------------------
c:0023 p:-17580534911092 s:0068 b:0068 l:000067 d:000067 TOP
eltiare / abuse.rb
Created Nov 22, 2011
Is this DRY or just plain abuse? :)
View abuse.rb
@users = User.all(if params[:verified]
{ needs_verification: false }
elsif params[:admin]
{ => 'admin' }
{ needs_verification: true }
eltiare /
Created Apr 6, 2011
Bash script to use the Rails' runner action via cron
cd `dirname $0`/../
rails runner script/${1}.rb