Skip to content

Instantly share code, notes, and snippets.

View nathancolgate's full-sized avatar

Nathan Colgate nathancolgate

View GitHub Profile
require 'arel/nodes/binary'
module Arel
module Nodes
class ContainedInHStore < Arel::Nodes::Binary
def operator; :"<@" end
end
class ContainedInArray < Arel::Nodes::Binary
def operator; :"<@" end
@nathancolgate
nathancolgate / rackspace_account_meta_temp_url_key.sh
Last active September 26, 2018 15:41
How to Set your Rackspace Temp URL Key (X-Account-Meta-Temp-Url-Key) from the command line
# General Reading: https://developer.rackspace.com/docs/cloud-files/v1/developer-guide/#document-public-access-to-your-cloud-files-account/tempurl
$ curl -v -H "X-Auth-User: <your_rackspace_username>" -H "X-Auth-Key: <your_rackspace_api_key>" https://auth.api.rackspacecloud.com/v1.0
* About to connect() to auth.api.rackspacecloud.com port 443 (#0)
* Trying 67.192.1.11... connected
* Connected to auth.api.rackspacecloud.com (67.192.1.11) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
@nathancolgate
nathancolgate / static_copy.sh
Created April 21, 2015 17:45
The modern Web is a dynamic place. However, sometimes it's necessary (or desirable) to remove the dynamic functionality of a website, while preserving its static content.
wget -P /path/to/destination/directory/ -mpck --user-agent="" -e robots=off --wait 1 -E https://www.example.com/
@nathancolgate
nathancolgate / svg_to_png.rb
Created November 8, 2013 16:21
Converting SVG content from Highcharts into PNGs to be embedded into a PDF. Eventually I settled on using prawn-svg (thanks, Matt!). But I thought this solution was interesting enough to retain.
@pngs = {}
timestamp = Time.now.to_i
Dir.mkdir("#{Rails.root}/tmp/rmagick") unless File.exists?("#{Rails.root}/tmp/rmagick")
Dir.mkdir("#{Rails.root}/tmp/rmagick/reports") unless File.exists?("#{Rails.root}/tmp/rmagick/reports")
Dir.mkdir("#{Rails.root}/tmp/rmagick/reports/#{timestamp}") unless File.exists?("#{Rails.root}/tmp/rmagick/reports/#{timestamp}")
params[:svgs].each do |key,svg|
string = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'+URI.unescape(svg)
string.gsub!("'lucida grande', 'lucida sans unicode', verdana, arial, helvetica, sans-serif",'') # classes_observed_by_grade_level
string.gsub!(/clip-path="url\(#highcharts-[0-9]*\)"/,'clip-path="none"') # classes_observed_by_grade_level
string.gsub!(' opacity="1"','') # classes_observed_by_grade_level
@nathancolgate
nathancolgate / jquery.watable.ie8.js
Created July 30, 2013 21:49
A safer Object.keys compatibility implementation for jquery.WATable so that it will work in IE8
/*
Throwing Object.keys error in IE8 fix:
http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
*/
Object.keys = Object.keys || (function () {
var hasOwnProperty = Object.prototype.hasOwnProperty,
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
DontEnums = [
'toString',
'toLocaleString',
@nathancolgate
nathancolgate / mime_types.rb
Last active November 18, 2018 15:17 — forked from ream88/excel_template_handler.rb
Example demonstrating the use of writeexcel gem in rails 3.2
# config/initializers/mime_types.rb
Mime::Type.register "application/vnd.ms-excel", :xls
@nathancolgate
nathancolgate / gist:5053019
Created February 27, 2013 23:57
Update: Sphinx 2.0.6 still not recognizing postgresql on 10.7.5 passing --pgsql
$ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install sphinx --pgsql
Warning: Using Clang, but this formula is reported to fail with Clang.
sphinxexpr.cpp:1802:11: error: use of undeclared identifier 'ExprEval'
We are continuing anyway so if the build succeeds, please open a ticket with
the subject
sphinx-2.0.6: builds with Clang-425-10.7
@nathancolgate
nathancolgate / gist:5052669
Created February 27, 2013 23:04
Update: Sphinx 2.0.6 still not recognizing postgresql on 10.7.5
$ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install sphinx
Warning: Using Clang, but this formula is reported to fail with Clang.
sphinxexpr.cpp:1802:11: error: use of undeclared identifier 'ExprEval'
We are continuing anyway so if the build succeeds, please open a ticket with
the subject
sphinx-2.0.6: builds with Clang-425-10.7
@nathancolgate
nathancolgate / gist:5031247
Last active December 14, 2015 04:49
Sphinx 2.0.6 not recognizing postgresql on 10.7.5
$ HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install sphinx
==> Downloading http://sphinxsearch.com/files/sphinx-2.0.6-release.tar.gz
Already downloaded: /Library/Caches/Homebrew/sphinx-2.0.6.tar.gz
/usr/bin/tar xf /Library/Caches/Homebrew/sphinx-2.0.6.tar.gz
==> Downloading http://snowball.tartarus.org/dist/libstemmer_c.tgz
Already downloaded: /Library/Caches/Homebrew/libstemmer_c.tgz
/usr/bin/tar xf /Library/Caches/Homebrew/libstemmer_c.tgz
==> ./configure --prefix=/usr/local/Cellar/sphinx/2.0.6 --disable-dependency-tracking --localstatedir=/usr/local/var --with-libstemmer --without-mysql
./configure --prefix=/usr/local/Cellar/sphinx/2.0.6 --disable-dependency-tracking --localstatedir=/usr/local/var --with-libstemmer --without-mysql
@nathancolgate
nathancolgate / Gemfile
Last active January 31, 2023 01:44
How I built a rails interface on top of the amazing IceCube ruby gem. Video of final product: http://youtu.be/F6t-USuWPag
# Add these two gems
gem 'ice_cube', '0.9.3'
gem 'squeel', '1.0.16'