Skip to content

Instantly share code, notes, and snippets.

View tordans's full-sized avatar

Tobias tordans

View GitHub Profile
@cbeddow
cbeddow / download_apiv4.py
Last active June 13, 2023 22:59
Python script for downloading data from Mapillary API v4 in a bounding box
import mercantile, mapbox_vector_tile, requests, json
from vt2geojson.tools import vt_bytes_to_geojson
# define an empty geojson as output
output= { "type": "FeatureCollection", "features": [] }
# vector tile endpoints -- change this in the API request to reference the correct endpoint
tile_points = 'mly_map_feature_point'
tile_traffic_signs = 'mly_map_feature_traffic_sign'
tile_coverage = 'mly1_public'
@rob-murray
rob-murray / console_out.rb
Created January 9, 2015 08:55
Update a Rails readonly field
2.1.5 :020 > User
=> User(id: integer, name: string, email: string, created_at: datetime, updated_at: datetime)
2.1.5 :021 > User.create(name: 'rob', email: 'orb@example.com')
(0.1ms) begin transaction
SQL (1.0ms) INSERT INTO "users" ("name", "email", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["name", "rob"], ["email", "orb@example.com"], ["created_at", "2015-01-09 08:50:31.962223"], ["updated_at", "2015-01-09 08:50:31.962223"]]
(0.8ms) commit transaction
=> #<User id: 2, name: "rob", email: "orb@example.com", created_at: "2015-01-09 08:50:31", updated_at: "2015-01-09 08:50:31">
2.1.5 :022 > User.first
User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> #<User id: 2, name: "rob", email: "orb@example.com", created_at: "2015-01-09 08:50:31", updated_at: "2015-01-09 08:50:31">
@AndiH
AndiH / README.md
Last active August 29, 2015 14:06
Graph generation for a bunch of pictures

Here are Python scripts to generate and analyze and print data of a bunch of pictures. I made them for our scout campsite, at which we generated 1700 pictures with five photographers in the summer of 2014.

You find a write-up in German here: http://static.andreasherten.de/2014/09/06/campsite-pictures.html

The scripts are a bit messy. I'm sorry for that.

Files

  • picStats.py gathers information and saves them into a JSON file
  • createPictureGraphs.py reads in this information, does some resorting and stuff, and uses pyplot (with prettyplotlib) to display them
  • compareYears.py looks at three different JSON files of three different years and display some graph.
#!/bin/bash
set -e -u
domain='http://geojson.io'
infile=''
if (uname | grep -q 'Darwin'); then
open='open'
else
open='xdg-open'
@pmeenan
pmeenan / user-timing-rum.js
Last active January 18, 2024 23:46
Support routine for adding W3C user timing events to a site. Includes some basic polyfill support for browsers that don't support user timing or navigation timing (though the start time for non-navigation timing support could be improved with IE < 9 to use IE's custom start event).
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
@marians
marians / database.sql
Created July 27, 2011 07:55
Snapshot of the script I wrote to generate http://vimeo.com/26157684
CREATE TABLE `stations` (
`id` varchar(9) COLLATE latin1_general_ci NOT NULL,
`postalcode` varchar(5) COLLATE latin1_general_ci NOT NULL,
`name` varchar(255) COLLATE latin1_general_ci NOT NULL,
`longitude` decimal(5,2) NOT NULL,
`latitude` decimal(5,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci COMMENT='BfS Sensor Stations';
CREATE TABLE `values_2h` (
@gr2m
gr2m / jquery.focus_select.js
Created May 1, 2011 00:21
$('input, select').focus_select() will focus the <select> and select the <input>. select does not work on <select>s
jQuery.fn.focus_select = function() {
return this.each(function(){
var $this = jQuery(this);
if ( $this.is('select') ) {
$this.focus()
} else {
$this.select()
}
})
}
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
#!/usr/bin/perl
# This script concatenates and minifies a given set of CSS and JavaScript files
# so that only one JS and one CSS file are the result.
#
# In order to make it work for your project, configure the path settings and the
# file names both for input and output files.
#
# by Marian Steinbach <marian@sendung.de>