Skip to content

Instantly share code, notes, and snippets.

View JamesChevalier's full-sized avatar

James Chevalier JamesChevalier

View GitHub Profile
@JamesChevalier
JamesChevalier / bootstrap_paginate.rb
Created July 1, 2013 13:35
Put in config/initializers Found through https://coderwall.com/p/wgyo7q (which provides another client-side option for displaying will_paginate with Bootstrap style.
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
protected

Clone the uptime repository

$ git clone https://github.com/fzaninotto/uptime.git

Go into the newly cloned repository

$ cd uptime

Login using heroku command line

gem 'activerecord', '3.2.12'
require 'active_record'
require "minitest/autorun"
require 'minitest/pride'
require 'logger'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do

Coderunner is an app for OSX that makes it easy to run quick bits of code in a variety of languages. It is perfect for someone just experimenting with a particular language. For working with Ruby, I like to use RVM not only use different versions of Ruby, but also to create very specific gemsets. Getting this functionality to work with Coderunner proved a bit of challenge as the documentation is lacking, so I thought I would post the steps I took.

In this example, I will go through the setting up of a RVM environment for Ruby 1.8.7-p357 with a gemset called "my-gemset". I have already created the gemset for this example using the rvm 1.8.7@my-gemset --create command. It is important to note that the RVM environment must be configured prior to applying the settings to Coderunner.

With the RVM environment setup, the next thing to do is open up the Coderunner preferences and look at the languages. There are quite a few

@JamesChevalier
JamesChevalier / osmosis_on_ec2.sh
Last active January 3, 2016 09:29 — forked from vallettea/gist:6726257
osmosis on ec2
# java 7
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo apt-get install -y oracle-java7-installer
# osmosis
wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.tgz
mkdir osmosis
tar -xvzf osmosis-latest.tgz -C osmosis
def self.circle_path(center, radius, complete_path = false)
# For increased accuracy, if your data is in a localized area, add the elevation in meters to r_e below:
r_e = 6378137.0
@@d2r ||= Math::PI/180
@@multipliers ||= begin
segments = 16
dRad = 2*Math::PI/segments
(segments + (complete_path ? 1 : 0)).times.map do |i|
rads = dRad*i
y = Math.sin(rads)
@JamesChevalier
JamesChevalier / AWSLambdaSimpleSMS.js
Created November 11, 2015 23:03 — forked from stevebowman/AWSLambdaSimpleSMS.js
AWS Lambda Function to send an SMS message via the Twilio API
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
console.log('Loading event');
var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB();
exports.handler = function(event, context) {
console.log("Request received:\n", JSON.stringify(event));
console.log("Context received:\n", JSON.stringify(context));
var tableName = "OurBlogDemo";
var datetime = new Date().getTime().toString();
@JamesChevalier
JamesChevalier / NominatimOnEC2.md
Created September 21, 2016 02:43 — forked from econandrew/NominatimOnEC2.md
Instructions for installing an OpenStreetMap Nominatim geocoder instance on Amazon Linux / EC2 (Dec 2014)

Installing Nominatim on Amazon Linux / EC2

  1. Introduction

The official instructions for installing Nominatim are complete, but brief in places, and several steps must be changed in the Amazon Linux environment (which is roughly CentOS / Redhat). The steps below are rough record of what I did to get it working, but I didn't keep perfect track so you shouldn't rely on them as a shell script. Just follow each step, make sure it worked, and hopefully you'll need to adapt very little (version numbers, for one thing). (I also skip in and out of root, but you can be more careful if you like.)

  1. Setting up the EC2 instance