Skip to content

Instantly share code, notes, and snippets.

View cjolly's full-sized avatar

Chad Jolly cjolly

  • Infotrack
  • Denver, CO
  • 19:15 (UTC -06:00)
View GitHub Profile
@cjolly
cjolly / pg.sh
Last active June 19, 2025 14:34
Use homebrew to upgrade to postgres on OSX
newpg=9.6.1 # set to new PG version number
oldpg=`pg_config --version | cut -d' ' -f2`
# PG 96. upgrades the readline to v7, which breaks anything linked against readline v6, like ruby via ruby-build.
# I *think* this should prevent it from installing v7. But if weird shit happens with various rubies,
# you'll have to reinstall them.
brew pin readline
# Stop current Postgres server
brew services stop postgresql
@cjolly
cjolly / README.md
Last active August 4, 2023 08:21
How to securely set rails secret key when you deploy to Heroku.

Stop Versioning Rails Secret Tokens

After reading Code Climate's Rails' Insecure Defaults I realized I was guilty of breaking rule 3. Versioned Secret Tokens. Here's how I fixed it.

Use dotenv in development and test environments:

# Gemfile
gem 'dotenv-rails', groups: [:development, :test]
@cjolly
cjolly / rewrite.rb
Created October 15, 2011 18:22
SEO on Rails or Rack
# As a general rule, I despise all things SEO with it's witchery and voodoo ways.
# However, these two practices are confirmed semi-non-witchcraft SEO best practice.
#
# 1. Serve your content from a consistent domain (www vs. non-www, Doesn't matter. Just be consistent)
# In addition this is nice for Heroku and other cloud based deployment environments that leave your app
# accessible from a url like http://myapp.herokuapp.com
#
# 2. Believe it or not, trailing slashes matter. The google machine interprets http://domain.com/about
# as a different page than domain.com/about/
# (source: http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html )
@cjolly
cjolly / autostart
Last active May 1, 2019 19:54
Raspberry PI Notes
# file: /etc/xdg/lxsession/LXDE/autostart
# sudo raspi-config # Enable Boot To Desktop
# idea via: http://lokir.wordpress.com/2012/09/16/raspberry-pi-kiosk-mode-with-chromium/
@lxpanel --profile LXDE
@pcmanfm --desktop --profile LXDE
# @xscreensaver -no-splash
@xset s off
@cjolly
cjolly / psqlrc.md
Last active August 9, 2017 15:37
You'll Never Guess What Was Causing RSpec to output "Time: 0.1234 ms"

When running specs I often see this output before the specs start to run.

> rspec spec
Time: 0.288 ms
Time: 0.110 ms
Time: 0.084 ms
Time: 0.095 ms
Time: 0.105 ms
Time: 0.115 ms
@cjolly
cjolly / sort.md
Last active April 30, 2017 09:48
How to identify malformed characters or illegal byte sequence in files

Legacy Data

When dealing with legacy data it's been pretty common to run into malformed / illegal byte sequences in files. Figuring out what's causing the issue is often really difficult, especially when the file has thousands of rows.

Here's a trick I pretty much stumpbled upon:

nl file.txt | sort

sort: string comparison failed: Illegal byte sequence
sort: Set LC_ALL='C' to work around the problem.
@cjolly
cjolly / godaddy-heroku-ssl.md
Last active August 6, 2016 21:44
How to use Heroku's SSL Endpoint with an SSL certificate purchased from GoDaddy

[UPDATED FOR #HEARTBLEED]

How to use Heroku's SSL Endpoint with an SSL certificate purchased from GoDaddy.

Heroku's docs on this are now the definitive source. I just followed their instructions to update my apps and they're much better than they were when I made this gist. Here's the previous revision if you need still need it. Good luck!

@cjolly
cjolly / geolocation-spec.js.coffee
Last active December 24, 2015 14:29
How to test javascript geolocation with jasmine
#= require support/jasmine-given
class Geolocation
getCurrentPosition: ->
options =
maximumAge: 0
timeout: 1*10*1000
enableHighAccuracy: true
navigator.geolocation.getCurrentPosition(@success, @failure, options)
@cjolly
cjolly / gist:4566810
Last active December 11, 2015 07:29
can't kill rspec, capybara, poltergeist with ctrl+c
1.9.3-p327 → rspec spec/requests/
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
Rack::File headers parameter replaces cache_control after Rack 1.5.
...^CF^C
An error occurred in an after hook
Errno::EPIPE: Broken pipe
occurred at /Users/cjolly/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/poltergeist-1.0.2/lib/capybara/poltergeist/web_socket_server.rb:144:in `write'
F
An error occurred in an after hook
@cjolly
cjolly / example.md
Created October 5, 2012 22:19
DateTime vs Time and ActiveRecord
>> ps.cancel_at
=> Fri, 05 Oct 2012 00:00:00 UTC +00:00
>> ps.cancel_at.class
=> ActiveSupport::TimeWithZone
>> ps.cancel_at = DateTime.new 2012, 11, 05
=> Mon, 05 Nov 2012 00:00:00 +0000
>> ps.save
   (0.2ms)  BEGIN
 Entity Load (0.5ms) SELECT "entities".* FROM "entities" WHERE "entities"."id" = 2485 LIMIT 1