Skip to content

Instantly share code, notes, and snippets.

@just3ws
just3ws / Gem list
Created March 16, 2011 12:54
RSpec fails when run via 'rake' but works as expected when run alone or via bundle exec spec.
abstract (1.0.0)
actionmailer (3.0.5)
actionpack (3.0.5)
activemodel (3.0.5)
activerecord (3.0.5)
activeresource (3.0.5)
activesupport (3.0.5)
annotate (2.4.0)
arel (2.0.9)
autotest-fsevent (0.2.5)
@just3ws
just3ws / Refactored.js
Created April 14, 2011 17:55
Toggles elements by their title as characters are typed into the text box.
// The character array as a queue was clever but poorly implemented and unnecessary.
// Instead, just read the query from the input.
// Also handles mouse driven content actions (cut, paste, etc).
$(function() {
var filter = function(query) {
var titlesSelector = "#content .show h3 a";
if (query == '') {
$(titlesSelector).closest(".show").show();
} else {
@txus
txus / Readme.md
Created June 18, 2012 21:36
Vimcov runs a Ruby script and opens Vim marking the lines that were actually run

vimcov

Vimcov runs a Ruby script and opens Vim marking the lines that were actually run.

This could be useful when debugging long methods with lots of branching -- instead of abusing puts, you can just use Vimcov and you're good to go.

It runs only in Ruby 1.9.x.

Future versions will include more tight integration with test runs or Rails or whatever.

@just3ws
just3ws / fucking_twitter.rb
Created December 4, 2012 17:10
Because Twitter eats whitespace...
# The example I tweeted about preferring the more verbose if..then..else..end
# over ternary operations in Ruby got mangled by Twitter.
# So when my tweet showed everything on one line my message got muddled.
# The reformatting of my tweet also looked like I was trying to evaluate
# an expression that returned literally "true" or "false" which wasn't the case.
# What I wanted to show was that many people write IF/ELSE statements as
# ternary operations.
@just3ws
just3ws / models_and_controllers_helpers.rb
Last active December 10, 2015 07:18
Rails console helpers to put in your .irbrc that will return an array of AR model constants and an array of controller constants respectively.
def self.models
ActiveRecord::Base
.send(:subclasses)
.map { |model| model.name.constantize }
end
def self.controllers
Rails.application.routes.routes
.select { |r| r.defaults[:controller].present? }
.uniq { |r| r.defaults[:controller] }
@just3ws
just3ws / ugtastic_interviewees_list
Created January 31, 2013 17:47
A list of everyone who's been interviewed for UGtastic. Not all published yet though.
Aaron Bedra
Aaron Holbrook
Aaron Kalin
Adam Grandy
Adewale Oshinye
Amy Kinney
Andrea Magnorsky
Andy Lester
Angelique Martin
Anthony Zinni & Jon Buda & Shay Howe
#!/usr/bin/env bash -x
apt-get -y update
# -------------------------------
# Based on bootstrap-ubuntu-12-04
# https://raw.github.com/fesplugas/rbenv-bootstrap/master/bin/rbenv-bootstrap-ubuntu-12-04
# Update sources:
apt-get -y update
@just3ws
just3ws / ubuntu_bootstrap_locale.sh
Last active December 15, 2015 01:59
Set the encoding to UTF-8 and the timezone to UTC on Ubuntu hosts.
#!/bin/bash -x
echo "LANG=\"en_US.UTF-8\"" >> /etc/environment
echo "LANGUAGE=\"en_US.UTF-8\"" >> /etc/environment
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/environment
source /etc/environment
apt-get install -y --reinstall locales
locale-gen en_US.UTF-8
@just3ws
just3ws / process.rb
Last active January 14, 2017 14:46
Leverage the "J" in JRuby for Powerful Concurrency
#!/usr/bin/env jruby
require_relative '../lib/schrute'
require 'csv'
require 'thread_safe'
java_import java.util.concurrent.Callable
java_import java.util.concurrent.Executors
java_import java.util.concurrent.FutureTask
@flavio
flavio / gemfile_lock2geminabox.rb
Created February 2, 2012 09:21
Parse Gemfile.lock, download all gems from rubygems and then upload them to a local instance of geminabox
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
require 'fileutils'
require 'net/http'
require 'net/https'
require 'uri'
TMP_DIR = "/tmp/gems"