Skip to content

Instantly share code, notes, and snippets.

@jamestyack
jamestyack / graph_gist_template.adoc
Created December 29, 2015 05:43 — forked from cheerfulstoic/graph_gist_template.adoc
CHANGEME: GraphGist Template. Fork to make your own, view source to see instruction comments

TITLE OF YOUR GRAPHGIST

Ruby script to convert stops.txt and shapes.txt to GeoJSON.

@jamestyack
jamestyack / gist:e34baa3beef23e1edc4d
Last active August 29, 2015 14:19
City Of Philadelphia Bike Share Stations Snippet
{
"geometry": {
"coordinates": [
-75.16374,
39.95378
],
"type": "Point"
},
"properties": {
"addressStreet": "1401 John F. Kennedy Blvd.",
@jamestyack
jamestyack / java8streams
Created March 25, 2015 20:19
Java8 Streams stuff
public class StreamsTest {
@Test
public void chapter2Stream1() {
String contents = "catch,catching,cat,cats,dog,eating";
String[] splitted = contents.split("[\\ P{ L}] +");
System.out.println(splitted);
String[] wordsArray = { "catch", "catching", "cat", "cats", "dog", "eating"};
Stream<String> stream = Arrays.stream(wordsArray, 1, wordsArray.length);
@jamestyack
jamestyack / gist:8dee2a8ea193e184cd02
Created January 30, 2015 05:26
Ruby moving back through dates a month at a time
def prev_month_list_based_on_1st_current_month(prev_month_range)
today = Date.today
beg_of_current_month = today - today.day + 1
prev_month_range.to_a.map { | prev_month_number | beg_of_current_month.prev_month(prev_month_number) }
end
@jamestyack
jamestyack / gist:545a2b7db2f57465cef6
Last active August 29, 2015 14:14
evographs import
<script>
evoGraphOptions = {
title: "Last 12 months: total days in month where elevator outage was reported <% if station %>at <%= station['stop_name'] %><% end %>",
data: [],
width: 700,
height: 350
};
$.get("/septa/elevator/outagedayslast12months/<%= station['_id'] %>", function( outageData ) {
$.each(outageData, function( index, value ) {
evoGraphOptions.data.push(value.month, value.outageDays)
@jamestyack
jamestyack / gist:269c2723846430e05de4
Created December 6, 2014 21:48
Mongo Aggregation examples
Query to group by a category (from shell)
db.products.aggregate ([
{"$group":
{
"_id":"$category",
"num_products":{"$sum":1}
}}
])
@jamestyack
jamestyack / gist:4da6be931ecaf3ef4c30
Last active August 29, 2015 14:06
Overpass-turbo Get wheelchair=yes cafes
<!--
This is an example Overpass query.
Try it out by pressing the Run button above!
You can find more examples with the Load tool.
-->
<query type="node">
<has-kv k="amenity" v="cafe"/>
<has-kv k="wheelchair" v="yes"/>
<bbox-query {{bbox}}/><!--this is auto-completed with the
current map view coordinates.-->