Skip to content

Instantly share code, notes, and snippets.

@IanVaughan
IanVaughan / uninstall_gems.sh
Created June 9, 2012 20:37
Uninstall all rbenv gems
#!/usr/bin/env bash
uninstall() {
list=`gem list --no-versions`
for gem in $list; do
gem uninstall $gem -aIx
done
gem list
gem install bundler
}
@kennyp
kennyp / git-by-date
Created February 26, 2013 20:30
If you need to sort files by creation date in git. ex. `find . -name '*.rake' | git by-date`
#!/usr/bin/bash
while read f
do
echo "$(git log --format="%at" --reverse "$f" | head -n1) --> $f"
done | sort -n
@stevenharman
stevenharman / defaults.rb
Last active July 7, 2021 14:36
A subtle difference between Ruby's Hash.fetch(:key, :default) vs. (Hash[:key] || :default)
h = {
'a' => :a_value,
'b' => nil,
'c' => false
}
h.fetch('a', :default_value) #=> :a_value
h.fetch('b', :default_value) #=> nil
h.fetch('c', :default_value) #=> false
h.fetch('d', :default_value) #=> :default_value
@lrhache
lrhache / heroku-set-configs-from-file.md
Created December 11, 2013 15:21
Easy way to batch set Heroku config from a file. No one wants to do this manually(!?).

#Heroku set configs from files

  • Export your configs from Heroku in "shell" format to file:

    $ heroku config -a <app_name> -s > .env-<environment_name(production, staging, ...)>
    
  • Copy this script to a file

@mlanett
mlanett / rails http status codes
Last active June 7, 2024 02:33
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@jadaradix
jadaradix / yosemite-subl
Last active January 25, 2022 05:22
Fix Sublime's "subl" command on OS X Yosemite.
rm /usr/local/bin/subl;
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl;
@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active June 11, 2024 09:29
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@georgiana-gligor
georgiana-gligor / osx-pdf-from-markdown.markdown
Last active March 5, 2024 21:09
Markdown source for the "Create PDF files from Markdown sources in OSX" article

Create PDF files from Markdown sources in OSX

When [Markdown][markdown] appeared more than 10 years ago, it aimed to make it easier to express ideas in an easy-to-write plain text format. It offers a simple syntax that takes the writer focus away from the formatting, thus giving her time to focus on the actual content.

The market abunds of editors to be used for help with markdown. After a few attempts, I settled to Sublime and its browser preview plugin, which work great for me and have a small memory footprint to accomplish that. To pass the results around to other people, less technical, a markdown file and a bunch of images is not the best approach, so converting it to a more robust format like PDF seems like a much better choice.

[Pandoc][pandoc] is the swiss-army knife of converting documents between various formats. While being able to deal with heavy-weight formats like docx and epub, we will need it for the more lightweight markdown. To be able to generate PDF files, we need LaTeX. On OSX, the s

@jweir
jweir / const_parse.rb
Last active May 2, 2023 21:09
Simple parse to find all constants in a Ruby file
require 'test_helper'
require 'ripper'
# see http://svenfuchs.com/2009/7/5/using-ruby-1-9-ripper
# Only finds contants which are referenced or defined via class
# does not find constants which are defined inline i.e. X=true
class ConstParser < Struct.new(:source)
def consts
consts = []
@celso
celso / init.vim
Last active March 8, 2024 18:31
Neovim setup for OSX users
syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.