Skip to content

Instantly share code, notes, and snippets.

View dliggat's full-sized avatar

Dave Liggat dliggat

View GitHub Profile
@dliggat
dliggat / bandwidth_crontab.sh
Last active August 29, 2015 13:55
Crontab to test bandwidth speed: 4 times a day
# Note 1: Necessary to reproduce $PATH so that the boxen location for wget is picked up by the cron daemon.
# Note 2: Pick an appropriate output location - currently this is set to a logging directory in Dropbox
PATH=/opt/boxen/nodenv/shims:/opt/boxen/nodenv/bin:bin:/opt/boxen/rbenv/shims:/opt/boxen/rbenv/bin:/opt/boxen/rbenv/plugins/ruby-build/bin:/opt/boxen/bin:/opt/boxen/homebrew/bin:/opt/boxen/homebrew/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
0 8,13,18,23 * * * wget --output-document=/dev/null --report-speed=bits http://speedtest.wdc01.softlayer.com/downloads/test10.zip 2>&1 | grep ') -' >> /Users/$USER/Dropbox/Logging/`hostname`-bandwidth.log
@dliggat
dliggat / rgba_to_hex.rb
Last active August 29, 2015 13:56
Convert RGBA to transparency + hex
vals = "255,0,0,0.8".split(',')
transparency = vals.pop.to_f
hex = "#%02x%02x%02x" % vals.map(&:to_i)
@dliggat
dliggat / photo_bin.rb
Created March 21, 2014 01:18
A ruby script to bin photos by year-month directories (assumes jpgs are in a standard ISO8601ish format; e.g. 2014-01-10_13-23-22.jpg).
#!/usr/bin/env ruby
require 'date'
require 'fileutils'
raise ArgumentError.new "Usage: #{$0} directory" unless ARGV.count == 1
root_dir = File.expand_path ARGV.first
Dir.glob "#{root_dir}/*.jpg" do |file|

Keybase proof

I hereby claim:

  • I am dliggat on github.
  • I am dliggat (https://keybase.io/dliggat) on keybase.
  • I have a public key whose fingerprint is A683 E518 CE53 D80E E0AE ABF3 E913 BB24 FEDA BC07

To claim this, I am signing this object:

@dliggat
dliggat / sublime_settings.json
Created May 30, 2014 15:39
Sublime settings
{
"auto_complete_commit_on_tab": true,
"auto_match_enabled": false,
"binary_file_patterns":
[
"*.doc",
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
@dliggat
dliggat / thirty_day_challenges.md
Created June 2, 2014 02:58
Thirty Day Challenges

Thirty-day Challenges:

  • 2014-05: No financial news, checking portfolio performance, etc
    • Very relaxing. Demonstrative of the reality that the markets carry out happily without intervention and without needing to be watched. A good reminder to focus on life and not monkey with financial stuff.
  • 2014-06: Hit 10,000 steps a day

Backlog

  • no caffeine
@dliggat
dliggat / mixin2.rb
Last active August 29, 2015 14:04
Module function collision => super calls most recent definition
module Foo
def blar
puts 'blar!'
end
end
module Bar
def blar
puts 'barry!'
end
@dliggat
dliggat / public_read.json
Created August 8, 2014 19:28
S3 Bucket Policy for all files public read: http://awspolicygen.s3.amazonaws.com/policygen.html
{
"Id": "Policy1407525880036",
"Statement": [
{
"Sid": "Stmt1407525872165",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::$BUCKET_NAME/*",
@dliggat
dliggat / production.rake
Created January 8, 2015 22:54
Dump a postgresql production database excluding migrations; and restore locally
namespace :production do
task sync: :environment do |t, args|
user_at_host = 'ubuntu@aws-host.com'
user_keypair = '-i ~/.ec2/gsg-keypair'
filename = Time.now.strftime "production_dump_%Y-%m-%d_%H-%M-%S.psql"
dump_path = "/tmp/#{filename}"
project = 'project'
# Dumping the table (excluding schema_migrations) on the server.
dump_command = ["pg_dump --exclude-table=schema_migrations",
0 * * * * echo `date` Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam diam elit, pellentesque eget mattis vitae, sodales quis quam. Aenean et bibendum felis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Quisque sed metus odio. Cras fermentum tincidunt gravida. Nullam tincidunt, quam at pretium adipiscing, leo lacus condimentum lorem, vitae euismod nisi erat ut dui. Pellentesque malesuada elementum nisl ut sagittis. Nulla sit amet odio leo. Phasellus consectetur lorem sed justo mattis cursus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. >> /tmp/foobar