Skip to content

Instantly share code, notes, and snippets.

View ajturner's full-sized avatar
🗺️
Considering WhereCamps

Andrew Turner ajturner

🗺️
Considering WhereCamps
View GitHub Profile
module Arel
class TwitterArray
include Relation
attr_reader :array, :attribute_names_and_types
include Recursion::BaseCase
ATTR_MAP = {
:twitter_name => Attributes::String,
:id => Attributes::Integer,
# (T) - Twitter Updates
# id = Arel::Attributes::Integer.new nil, :id
# update = Arel::Attributes::String.new nil, :update
# tuples = [[1, "Hai I can haz cheezburgerz"], [2, "Nom!"], [0, "What can you haz?"]]
# headers = [Arel::Attributes::Integer.new(nil, :id), Arel::Attributes::String.new(nil, :update)]
# updates = Arel::Array.new tuples, headers
# find_twitter_user_updates_predicate = Arel::Predicates::Equality.new updates[:id], 9
# from http://blog.portable-eggplant.org/2007/02/13/ruby-polyline-encoder-for-google-maps/
class EncodedPolyline
attr_reader :points, :encoded_points, :encoded_levels
def initialize(points, culling_level = 0)
@points = points
points = []
for point in @points
points << Hash["lat" => point.y, "long" => point.x, "lev" => "unset"]
end
@ajturner
ajturner / EncodedPolyline.js
Created November 21, 2010 22:32
Javascript tools for encoding polylines
// PolylineEncoder.js copyright Mark McClure April/May 2007
//
// This software is placed explicitly in the public
// domain and may be freely distributed or modified.
// No warranty express or implied is provided.
//
// History:
// V 2.1 July 2007
// Minor modification in distance function to enhance
// speed. Suggested by Joel Rosenberg.
@ajturner
ajturner / EncodedPolyline.as
Created December 8, 2010 16:17
Decodes an encoded polyline
package com.maker.models
{
public class EncodedPolyline {
private static var instance:EncodedPolyline;
public function EncodedPolyline() {}
private static function _decodeLine(encoded:String):Array {
@ajturner
ajturner / OPTIONS.rb
Created February 17, 2011 21:10
make Rails respond to an HTTP OPTIONS method request
# Add to routes.rb
# Needed for responding to OPTIONS http method
map.connect '*path',
:controller => 'home',
:action => 'options_for_mopd',
:conditions => {:method => :options}
# in home_controller.rb
<script src="http://geocommons.com/javascripts/f1.api.js" type="text/javascript"></script>
<style type="text/css" media="screen">
#map {width: 100%; height: 400px;}
</style>
<div id="embed_map"></div>
<div id="results"></div>
<script type="text/javascript" charset="utf-8">
var mymap = new F1.Maker.Map({
map_id: 48852,
dom_id: "embed_map",
@ajturner
ajturner / getLayers.js
Created May 17, 2011 15:35
Demonstration of map.getLayers
mymap.getLayers();
var layers = mymap.getLayers();
// Ouput:
// layers = [
// {
// title: "My First Layer",
// source: "finder:45",
// styles: {...},
// opacity: 1,
@ajturner
ajturner / setStyleLegend.js
Created May 19, 2011 13:09
example of GeoIQ setStyle
mymap.setStyle({legend:{buttonBgColor:0xFF00FF,buttonPlacement:"vertical",buttonFontColor:0x000000,buttonBgAlpha:1,offset:{x:30,y:0}}})
@ajturner
ajturner / setStyleZoom.js
Created May 19, 2011 13:14
Example of GeoIQ setStyle for the zoom
mymap.setStyle({zoom:{ bgColor:0x000000,iconColor:0xFFFFFF, bgAlpha:0.5, expanded:false, dropShadow:false, offset:{x:30,y:0},width:40}})