Skip to content

Instantly share code, notes, and snippets.

@mislav
mislav / fat-logfiles.sh
Last active December 22, 2018 19:56
Find "*.log" files in your home dir, sort them by fattest-first, and calculate the size of them all together.
find ~ -name '*.log' -print0 | xargs -0 -L1 stat -f'%z %N' | sort -rn | tee fat-logfiles.txt | head
awk '{ total += $1 } END { printf "total: %5.2f MiB\n", total/1024/1024 }' < fat-logfiles.txt
@rkh
rkh / gist:4644647
Last active December 11, 2015 18:49

The Hunt for the right HTTP library

Use case: Travis CLI. One command invokes one or more sequential HTTP requests.

Note that startup time and the first request are very significant for a command line tool like this.

Clone the repo if you want to follow along.

Note: numbers might be due to how libraries are used (via faraday)

anonymous
anonymous / ruby.rb
Created January 25, 2013 22:48
Stripped down rbenv package install
include_recipe 'rbenv::system_install'
node['rbenv']['rubies'].each do |ruby|
execute "Install ruby #{ruby}" do
command "tar xvfz /opt/chef-solo/current/vendor/rbenv-system-ubuntu-12.04-#{ruby}-x86_64.tar.gz"
cwd "/usr/local/rbenv/versions"
only_if do
!File.exists?("/usr/local/rbenv/versions/#{ruby}")
end
end
include_recipe "apt"
apt_repository "brightbox" do
uri 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu'
distribution node.lsb.codename
components ['main']
keyserver "keyserver.ubuntu.com"
key "C3173AA6"
action :add
end
@pvh
pvh / gist:4634543
Last active December 11, 2015 17:28
Postgres: The Bits You Haven't Found talk
A Beastiary of Badassery
-
SQLisms
--
WITH
arrays and unnest
window functions
JSON
row types
@andrew
andrew / leaderboard.rb
Last active December 10, 2015 23:38
Get a leaderboard of contributions in your GitHub organization
## Contribution leaderboard
#
# Get a leaderboard of contributions in your org
#
# usage: $ USERNAME=yourusername PASSWORD=yourpassword ORG=yourorgname ruby leaderboard.rb
#
# n.b requires the octokit and mechanize gems
require 'rubygems'
require 'octokit'
@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

@mislav
mislav / _selfdoc.sh
Last active December 10, 2015 12:58
Self-documenting shell program by Sam Stephenson https://twitter.com/sstephenson/status/285487626570579968
# Print the current shell script’s initial comment block, sans leading `# `
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
@metaskills
metaskills / gist:4369168
Created December 24, 2012 12:59
MiniTest::Emoji Customzations
MiniTest::Emoji::DEFAULT.merge! '.' => "\u{1f49A} ", 'F' => "\u{1f494} ", 'E' => "\u{1f480} ", 'S' => "\u{1f49B} "
@ndarville
ndarville / business-models.md
Last active February 27, 2025 10:00
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google