Skip to content

Instantly share code, notes, and snippets.

View ryansobol's full-sized avatar

Ryan Sobol ryansobol

  • Ryan Sobol LLC
  • Seattle, WA
  • 13:53 (UTC -07:00)
View GitHub Profile
#!/bin/sh
# because gconftool doesn't have "append"
glist_append() {
local type="$1"; shift
local key="$1"; shift
local val="$1"; shift
local entries="$(
{
git config --global push.default simple
git config --global credential.helper 'cache --timeout=3600'
postgres: postgres -D db/postgres
git config --global push.default simple
git config --global credential.helper osxkeychain
git config --global alias.c 'commit -m'
git config --global alias.st 'status --short --branch'
git config --global alias.ca 'commit --amend --reuse-message=HEAD'
git config --global alias.co 'checkout'
git config --global alias.br 'branch'
git config --global alias.df 'diff HEAD'
git config --global alias.ir $'!sh -c \'git rebase --interactive ${1-master}\' -'
git config --global alias.ll 'log --graph --all --pretty=format:"%Cred%h %>(11,trunc)%Cgreen%cr %<(10,trunc)%Cblue%cn%C(yellow)%d %Creset%s"'
git config --global alias.la 'log --patch --stat --pretty=format:"%C(bold red)%h %Cgreen%cr %Cblue%cn%C(yellow)%d %Creset%s"'
git config --global alias.dfs 'diff --staged'
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:AUTO_INDENT] = true
class ResourcesController < ApplicationController
# GET /resources
def index
@resources = Resource.all
end
# GET /resources/1
def show
@resource = Resource.find(params[:id])
end
# POST /articles
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article, notice: 'Article was successfully created.'
else
render :new
end
end
@ryansobol
ryansobol / set_literals.rb
Created April 27, 2014 01:28
It's fun to dream what a literal syntax for Ruby's Set class might look like...
# generic literal of symbols
<:earth, :wind, :fire>
# => Set.new [:earth, :wind, :fire]
# %e literal of symbols without interpolation
%e<earth wind fire>
# => Set.new [:earth, :wind, :fire]
# %E literal of symbols with interpolation
element = :wind
#!/usr/bin/env ruby
#
# Shorten a GitHub URL to a git.io URL
# v1.2.0 - Copyright (c) 2016 Ryan Sobol - The MIT License
#
# Usage: gitio URL [code]
#
# Examples:
# $ gitio https://github.com/ryansobol ryansobol
# https://git.io/ryansobol