Skip to content

Instantly share code, notes, and snippets.

@taylor
taylor / gist:1843031
Created February 16, 2012 07:43
foreman in Procfile on Heroku
$ cat Procfile
foreman: foreman start -c web=1 worker=10 -f Procfile2
$ cat Procfile2
web: bundle exec rails s -p $PORT thin
worker: ruby worker.rb
@sjmulder
sjmulder / lostfound.rb
Created November 7, 2012 14:14
Quickly search through a reflog
#!/usr/bin/ruby
# Some bash-fu should be able to do the same but I'm only a white belt
if ARGV.length < 1
$stderr.puts 'usage: lostfind <keyword> [<keyword> ...]'
else
reflog = `git reflog`
reflog.each_line do |line|
hash, _, message = line.split(' ', 3)
@willurd
willurd / web-servers.md
Last active June 30, 2025 08:23
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@dwbutler
dwbutler / iso8601.rb
Last active July 7, 2024 06:33
Parsing ISO8601 Time format with Ruby
require 'time'
require 'benchmark'
time = Time.now.iso8601(3)
# => "2014-05-26T23:26:08.628-07:00"
Benchmark.bm do |x|
x.report('parse') { 100_000.times { Time.parse(time).gmtime } }
x.report('iso8601') { 100_000.times { Time.iso8601(time).gmtime } }
end
@peterflynn
peterflynn / Useful GitHub bookmarklets
Last active December 28, 2024 15:09
GitHub comment thread bookmarklets
To use: create a new bookmark and paste into the URL field.
In Chrome, you can paste the full multiline code as shown below.
In other browsers, you may need to minify the code into one line first.
@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active June 30, 2025 17:24
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@joyrexus
joyrexus / README.md
Last active June 12, 2025 20:55
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@straight-shoota
straight-shoota / memoize.cr
Created June 7, 2017 21:30
Memoize in Crystal
macro memoize(type_decl, &block)
@{{type_decl.var}} : {{ type_decl.type }} | UninitializedMemo = UninitializedMemo::INSTANCE
def {{type_decl.var}}
if (value = @{{type_decl.var}}).is_a?(UninitializedMemo)
@{{type_decl.var}} = begin
{{block.body}}
end
else
value
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active June 28, 2025 20:00
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@redrick
redrick / rspec_rails_cheetsheet.rb
Last active October 23, 2022 21:00 — forked from nerdinand/rspec_rails_cheetsheet.rb
New expect syntax + new hash syntax and couple corrections
#Model
expect(@user).to have(1).error_on(:username) # Checks whether there is an error in username
expect(@user.errors[:username]).to include("can't be blank") # check for the error message
#Rendering
expect(response).to render_template(:index)
#Redirecting
expect(response).to redirect_to(movies_path)