Skip to content

Instantly share code, notes, and snippets.

Jacob Swanner jswanner

Block or report user

Report or block jswanner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jswanner
jswanner / nulls_last.rb
Created Sep 13, 2012
ActiveRecord Postgres Nulls Last
View nulls_last.rb
ActiveSupport.on_load(:active_record) do
module Arel::NullsLastPredications
def nulls_last
Arel::Nodes::NullsLast.new self
end
end
module Arel::Nodes
class NullsLast < Unary
def gsub *args
View components.video-js.js
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement: function() {
this._super();
this.player = videojs(this.$('video')[0], null, function() {
this.play();
});
},
didRender: function() {
View running-script
$ chmod +x wc.rb
$ echo "hello, world" | ./wc.rb
1 2 13
$ printf "line 1\nline 2\n" | ./wc.rb
2 4 14
View wc.rb
#! /usr/bin/env ruby
require 'bundler/inline'
gemfile do
gem 'rspec', '3.7', require: false
end
class Program
def initialize(input)
View running-specs
$ rspec wc.rb
....
Finished in 0.00348 seconds (files took 0.19061 seconds to load)
4 examples, 0 failures
View script-spec.rb
# script logic
if $PROGRAM_NAME == __FILE__
# the script itself is being executed
exit
end
require 'rspec'
RSpec.describe 'the script' do
View bundler-inline.rb
require 'bundler/inline'
gemfile do
gem 'rspec', '3.7', require: false
end
@jswanner
jswanner / migrate.rake
Last active Dec 6, 2017
Rolls back migrations in current branch not present in specified branch.
View migrate.rake
desc 'rolls back migrations in current branch not present in other'
task :rollback_branch_migrations, [:other_branch] do |t, args|
load "#{Dir.pwd}/Rakefile"
branch_migrations = BranchMigrations.new(args.other_branch)
puts ['Rollback the following migrations', branch_migrations, 'y,n? ']
next if %w[no n NO N].include?(STDIN.gets.chomp)
Rake::Task['environment'].invoke
@jswanner
jswanner / Gemfile.diff
Created Oct 7, 2011
Differences between Rails 3.1.0 & Rails 3.1.1 generated apps
View Gemfile.diff
diff -U 0 -r rails-3.1.0/Gemfile rails-3.1.1/Gemfile
--- rails-3.1.0/Gemfile 2011-10-07 12:07:06.000000000 -0400
+++ rails-3.1.1/Gemfile 2011-10-07 12:59:13.000000000 -0400
@@ -3 +3 @@
-gem 'rails', '3.1.0'
+gem 'rails', '3.1.1'
@@ -14,3 +14,3 @@
- gem 'sass-rails', " ~> 3.1.0"
- gem 'coffee-rails', "~> 3.1.0"
- gem 'uglifier'
@jswanner
jswanner / .tmux.conf
Last active Mar 24, 2016
My tmux conf
View .tmux.conf
unbind C-b
set -g prefix C-a
set -g default-terminal "screen-256color"
set -g history-limit 5000
bind C-a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
You can’t perform that action at this time.