Skip to content

Instantly share code, notes, and snippets.

@lhammond
lhammond / rails.rb
Last active August 29, 2015 14:25
Use SSL in Rails development. First: to create a local SSL certificate and start a SSL webserver checkout *shell.sh*. Second: to configure Rails checkout *rails.rb*
# To enable SSL in Rails you could now simply use *force_ssl* in your
# ApplicationController but there is two more things to think about:
# In development our SSL webserver is running on port 3001 so we would
# actually need to use *force_ssl port: 3001* but then this wouldn't
# work for production.
# Also there is a good chance you might not always want to use SSL in development
# so it would be nice if we could just enable or disable SSL in the config.
# To make all this work first copy the file *ssl_with_configured_port.rb* to
# your *lib* directory. Second to enable SSL add *config.use_ssl = true*
@lhammond
lhammond / gist:5b6b2259efde3a20cb4a
Created January 26, 2016 21:27 — forked from zhm/gist:2005158
Building GDAL 1.9 with ESRI FileGDB support on OS X Lion

Building GDAL 1.9.x with ESRI FileGDB support on OS X Lion

  • Download the SDK from ESRI's website http://resources.arcgis.com/content/geodatabases/10.0/file-gdb-api
  • Extract the SDK, and put the contents of the directory in a known location, I used ~/local/filegdb. Here's an example path to one of the files: ~/local/filegdb/lib/libFileGDBAPI.dylib
  • I use ~/local/filegdb so it can stay isolated in it's own place. You can put it anywhere, but the next few steps might be different.
  • Go into the directory containing the FileGDB SDK, e.g. ~/local/filegdb
  • ESRI built these dylib's using @rpath's, so to avoid needing to mess with DYLD_LIBRARY_PATH, I updated the @rpath's using install_name_tool. There might be a more elegant way to handle this. If so, comments are welcome!
  • Here are the commands I used to patch the dylibs, this is not required if you want to use DYLD_LIBRARY_PATH yourself:
@lhammond
lhammond / gist:b289c928a45c884cdddd
Created February 1, 2016 18:05 — forked from pjsvis/gist:6210002
Angular directive for jQuery sparkline
// Requires jQuery from http://jquery.com/
// and jQuerySparklines from http://omnipotent.net/jquery.sparkline
// AngularJS directives for jquery sparkline
angular.module('sparkline', []);
angular.module('sparkline')
.directive('jqSparkline', [function () {
'use strict';
return {
@lhammond
lhammond / GeoJsonMapLayer.js
Created September 27, 2016 16:45 — forked from fab1an/GeoJsonMapLayer.js
React / Leaflet combination
export default class GeoJsonMapLayer extends React.Component {
render() {
return (
<div>
</div>
);
}
componentWillUnmount() {
if (this.layer) {
@lhammond
lhammond / launch_instance.rb
Created January 4, 2017 19:46 — forked from matthutchinson/launch_instance.rb
Launching EC2 instance with aws-sdk gem
#!/usr/bin/ruby
# README
# gem install aws-sdk
# add this to bashrc
# export HT_DEV_AWS_ACCESS_KEY_ID=????
# export HT_DEV_AWS_SECRET_ACCESS_KEY=????
# put your pem file in ~/.ssh and chmod 0400
# for more info see; https://rubygems.org/gems/aws-sdk
@lhammond
lhammond / mapserver_nginx
Last active August 5, 2021 14:24 — forked from yodeski/mapserver_nginx
Install Mapserver to run as FastCGI over Nginx
sudo apt-get install libgd2-xpm-dev
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libgdal20 libgeos-c1v5 libmapserver2 cgi-mapserver mapserver-bin
sudo apt-get install spawn-fcgi
create /etc/init.d/mapserv
add the following
@lhammond
lhammond / rails-jsonb-queries
Created February 28, 2018 22:39 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@lhammond
lhammond / .dockerignore
Created April 20, 2020 16:20 — forked from ksmithut/.dockerignore
Node Docker Compose nodemon
node_modules
@lhammond
lhammond / .asoundrc
Created April 12, 2021 23:56 — forked from italic-r/.asoundrc
ALSA - Signalink USB
# Use this file for a user-configurable ALSA soundcard setup.
# Place in the user's home folder (/home/ham/.asoundrc).
# This file is built for a Tigertronics Signalink USB, a USB
# soundcard designed to interface a computer with an amateur
# radio transceiver for digital mode operation. This
# configuration allows multiple programs to access the same
# sound device simultaneously without blocking the device.
# This configuration is built on a custom modprobe
# configuration file (/etc/modprobe.d/alsa-base.conf) to