Skip to content

Instantly share code, notes, and snippets.

View derekprior's full-sized avatar

Derek Prior derekprior

View GitHub Profile
@schneems
schneems / .rb
Created November 23, 2015 19:54
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', github: "rails/rails"
gem 'arel', github: "rails/arel"
gem "rack", github: "rack/rack"
gem "sprockets", github: "rails/sprockets"
gem "sprockets-rails", github: "rails/sprockets-rails"
gem 'coffee-rails', github: "rails/coffee-rails"
config :my_app, :twitter_api,
client: Twitter.SandboxClient
@henrik
henrik / yosemite_upgrade_notes.md
Last active December 30, 2015 02:29
Yosemite upgrade notes

Yosemite upgrade notes

From a (mostly) Ruby on Rails developer.

After doing the below everything seems to work (some of it worked before doing anything), including Ruby, Gems, RVM, Homebrew, VirtualBox/Vagrant VMs, Pow, tmux, git, vim.

  1. Did a full-disk backup that I can restore from
  2. Moved out /usr/local to avoid super slow install, per option 1 in https://jimlindley.com/blog/yosemite-upgrade-homebrew-tips/: sudo mv /usr/local ~/local
  3. Upgraded to Yosemite
  4. Restored /usr/local, per option 1 in https://jimlindley.com/blog/yosemite-upgrade-homebrew-tips/: sudo mv ~/local /usr
#!/usr/bin/env bash
branch_pattern="^## (.*)$"
git_status=`git status -sb`
if [[ $git_status =~ $branch_pattern ]]
then
echo ${BASH_REMATCH[1]}
fi
@mislav
mislav / _readme.md
Last active March 28, 2024 00:47
tmux-vim integration to transparently switch between tmux panes and vim split windows

I use tmux splits (panes). Inside one of these panes there's a Vim process, and it has its own splits (windows).

In Vim I have key bindings C-h/j/k/l set to switch windows in the given direction. (Vim default mappings for windows switching are the same, but prefixed with C-W.) I'd like to use the same keystrokes for switching tmux panes.

An extra goal that I've solved with a dirty hack is to toggle between last active panes with C-\.

Here's how it should work:

@mcmoyer
mcmoyer / application_helper.rb
Last active December 11, 2015 23:48
my general coffeescript/javascript style
#embed this in your body tag
# %body{body_data}
def body_data
{
:"data-controller" => params[:controller],
:"data-action" => params[:action],
:"data-id" => params[:id],
:"data-parent-controller" => parent_controller,
:"data-parent-id" => params["#{parent_controller.to_s.singularize}_id".to_sym]
@bf4
bf4 / ruby_learning.md
Last active July 17, 2021 08:06
Some Ruby Learning Resources

Useful Vim mappings

...you didn't know you wanted

Convert Ruby 1.8 to 1.9 hash syntax

nnoremap <Leader>: :%s/:\([^ ]*\)\(\s*\)=>/\1:/gc<CR>
@panthomakos
panthomakos / benchmark.rb
Created May 3, 2012 20:06
Benchmark Your Bundle
#!/usr/bin/env ruby
require 'benchmark'
REGEXPS = [
/^no such file to load -- (.+)$/i,
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
/^Missing API definition file in (.+)$/i,
/^cannot load such file -- (.+)$/i,
]
class User < ActiveRecord::Base
attr_accessible :name
has_many :admin_memberships, class_name: "Membership", conditions: {role: 'admin'}
has_many :editor_memberships, class_name: "Membership", conditions: {role: 'editor'}
def admin?
admin_memberships.exists?
end