Skip to content

Instantly share code, notes, and snippets.

@etipton
etipton / Eric Working Preferences.md
Last active January 12, 2021 14:27
Eric working preferences

NOTE: These are subject to change over time :)

ALSO NOTE: These are just preferences, I'm not totally inflexible on anything!

Scheduled meetings: anytime Mondays or Tuesdays; for other days: 9:30 - 11am, 3:30-5pm

I'd prefer NOT to work from 5pm-9pm (family time)

For Slack:

@etipton
etipton / upgrade_mysql.md
Created August 11, 2016 23:47
Upgrade brew-installed mysql from 5.6.22 to 5.7.11
  1. $ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist (stop mysql)
  • $ brew update
  • $ cd /usr/local/Library/Formula/
  • $ git checkout deff2feda710790d62aeb54286c097a6d991b3f1 (contains 5.7.11 build)
    • (may need to do a $ git pull origin master --unshallow first)
  • $ brew upgrade mysql
  • Apply server args:
    • NOTE: In general, always make sure you trust the source and don't "blindly" run files you download via curl.
    • $ ruby <(curl -s https://gist.githubusercontent.com/etipton/8dead5a3397f6bd7edb2/raw) (source code)
  • $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist (start mysql)
@etipton
etipton / rails_tzs.md
Last active February 15, 2016 10:56
Rails TZs

So... dealing with dates and timezones is always tricky in ruby (and, well, in software in general) --

Ruby Date objects don't have a concept of timezones, but Rails adds the concept of TimeWithZone for dealing with Time objects.

It's important also to note that timestamps are stored in the db without a timezone, and it's up to the application layer to apply the timezone.

In RenterUp, we allow timezones for billing purposes to be set at the property level. Most apps have a per-user timezone. We don't have that yet (but we should eventually add it).

Anyway, for billing purposes, currently we set all due dates to a second before midnight (23:59:59) on the bill's due date. If you look at the overridden Bill#due_by method, you can see where we apply the property's timezone to the timestamp.

@etipton
etipton / mysqlopts.rb
Last active August 4, 2016 07:53
Specify settings in mysql launchctl plist file
#!/usr/bin/env ruby
plist_file = File.expand_path('~/Library/LaunchAgents/homebrew.mxcl.mysql.plist')
File.open(plist_file, 'r+') do |f|
contents = f.read
args_end = ' </array>' # this is kinda brittle, but whatever
charset_opt = ' <string>--character-set-server=latin1</string>'
collate_opt = ' <string>--collation-server=latin1_swedish_ci</string>'
@etipton
etipton / tcp.rb
Last active January 7, 2016 12:47
Ruby TCP server, port 2000
#!/usr/bin/env ruby
require 'socket'
server = TCPServer.new(2000)
loop do
sock = server.accept
# sleep 6 # if you want to test timeouts
@etipton
etipton / aws_to_env.rb
Last active September 6, 2015 20:11
Convert downloaded AWS access creds to env vars
#!/usr/bin/env ruby
# Use ENV var if needed, e.g. ".zshenv"
shell_init_file = File.expand_path(ENV['SHELL_INIT_FILE'] || '~/.bash_profile')
aws_creds_file = File.expand_path(ENV['CREDS_FILE'] || '~/Downloads/credentials.csv')
require 'csv'
csv = CSV.parse(File.read(aws_creds_file), headers: true)
row = csv.first.to_hash
File.open(shell_init_file, 'a') do |f|
@etipton
etipton / gist:ac0ea70c70dcbdc7bacf
Created October 30, 2014 06:43
rack-timeout 0.1.0 + WEBrick issue
Erics-MacBook-Pro-3:renterup_api tipton$ be rails s
=> Booting WEBrick
=> Rails 4.1.6 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-10-30 02:39:13] INFO WEBrick 1.3.1
[2014-10-30 02:39:13] INFO ruby 2.1.3 (2014-09-19) [x86_64-darwin14.0]
[2014-10-30 02:39:13] INFO WEBrick::HTTPServer#start: pid=77070 port=3000
source=rack-timeout id=56a9f1828b7a2ef3d9321350ce43981a timeout=15000ms state=ready