Skip to content

Instantly share code, notes, and snippets.

@radcliff
radcliff / droughtshapes_controller.rb
Created July 24, 2014 03:22
Ruby method to convert geojson to topojson in Rails API
class DroughtshapesController < ApplicationController
include ApplicationHelper
def index
if params[:s]
state_name = params[:s].split.map {|i| i.capitalize}.join(" ")
state = State.find_by(name: state_name)
if state
shapes = state.drought_shapes
geojson_shapes = to_geojson(shapes)
@radcliff
radcliff / geojson_helper.rb
Last active August 29, 2015 14:04
drought-monitor-api helpers
module GeojsonHelper
# this method takes in a RGeo geometry object and returns a GeoJSON object
def to_geojson(geometry_collection)
geojson_object = {}
geojson_object["type"] = "FeatureCollection"
geojson_object["features"] = []
geometry_collection.each_with_index do |record, index|
@radcliff
radcliff / intro-to-jekyll.md
Created June 15, 2014 23:50
Introduction to Jekyll

Jekyll

Static Websites and Blogs

COOL STUFF
Written in Ruby
Uses Markdown for content generation
Integrates with GitHub Pages

###What is Jekyll?

@radcliff
radcliff / hangman.html
Created June 3, 2014 22:56
Hangman in AngularJS
<!DOCTYPE html>
<html>
<head>
<script src="http://jashkenas.github.io/underscore/underscore-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js"></script>
<script src="script.js"></script>
<meta charset="utf-8">
<title>HangMan</title>
</head>
<body ng-app>
@radcliff
radcliff / muliplication.rb
Created April 8, 2014 17:10
Prints a multiplication table.
# Prints a multiplication table
puts "Please specify the number of rows and colums:"
size = gets.chomp.to_i
if size > 0
puts "A multiplication table:"
puts
@radcliff
radcliff / ascii.rb
Created April 8, 2014 01:38
A simple ruby program that prints an ASCII art triangle.
#Simple ASCII Art
puts "What character do you want to make the pyramid out of?"
character = gets.chomp
puts "How many rows of #{character}'s do you want?"
row_count = gets.chomp.to_i
character_count = 1
width = 100