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)
@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 February 28, 2025 00:51
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 December 30, 2024 01:37
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 March 4, 2025 14:02
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)
@odlp
odlp / bundler-rspec-inline.rb
Created August 9, 2018 09:43
Inline Bundler and autorun RSpec
require "bundler/inline"
gemfile do
gem "rspec"
end
require "rspec/autorun"
RSpec.describe "inline Bundler and autorun RSpec" do
it "is convenient for self-contained examples & bug repros" do