Skip to content

Instantly share code, notes, and snippets.

View gordonbanderson's full-sized avatar

Gordon Anderson gordonbanderson

  • Nonthaburi, Thailand
View GitHub Profile
@gordonbanderson
gordonbanderson / HtmlEditorField.js
Created July 20, 2015 12:42
Modified version of HtmlEditorField.js, SilverStripe 3.13, with addition of console logging. See https://github.com/silverstripe/silverstripe-cms/issues/1166
/**
* Functions for HtmlEditorFields in the back end.
* Includes the JS for the ImageUpload forms.
*
* Relies on the jquery.form.js plugin to power the
* ajax / iframe submissions
*/
var ss = ss || {};
/**
<?php
class Grocery extends DataObject {
private static $db = array(
'Name' => 'Varchar(255)',
'Price' => 'Int'
);
private static $belongs_many_many = array(
'GroceryPages' => 'GroceryPage'
@gordonbanderson
gordonbanderson / videosheet.rb
Created June 6, 2015 06:12
Create 5x5 grid thumbnail sheet of all mp4 files in a given directory - pipe the output of this script into bash
puts "mkdir thumbs"
Dir.glob('*.mp4').sort.select{ |e|
filename = "#{e}"
percents = []
(4..100).step(4) do |n|
percents << n
end
@gordonbanderson
gordonbanderson / gist:44c1b36c3b861062253f
Created September 28, 2014 07:11
Using gpscorrelate to geolocate photographs, matching location from a GPX file using the time of the photograph
gpscorrelate -v -g RK_gpx\ _2014-09-27_0948.gpx *.JPG
EXIF-GPS Photo matching program.
Daniel Foote, 2005.
Reading GPS Data...
Correlate:
IMG_8962.JPG: Interpolated: Lat 13.680397, Long 100.584767, Elev 5.000000.
IMG_8984.JPG: Exact match: Lat 13.677067, Long 100.582568, Elev 3.900000.
IMG_8986.JPG: Interpolated: Lat 13.676461, Long 100.582233, Elev 3.500000.
@gordonbanderson
gordonbanderson / gspcorrelate-test
Created September 28, 2014 07:09
Using gpscorrelate in test mode to geolocate photographs
> gpscorrelate -v -n -g RK_gpx\ _2014-09-27_0948.gpx *.JPG
EXIF-GPS Photo matching program.
Daniel Foote, 2005.
Reading GPS Data...
Correlate:
IMG_8962.JPG: Interpolated: Lat 13.680397, Long 100.584767, Elev 5.000000.
IMG_8984.JPG: Exact match: Lat 13.677067, Long 100.582568, Elev 3.900000.
IMG_8986.JPG: Interpolated: Lat 13.676461, Long 100.582233, Elev 3.500000.
@gordonbanderson
gordonbanderson / Example
Created November 10, 2013 13:34
This is an example Gist
This is an example Gist
$map->setClusterer( true );
public function MapWithDataList() {
$flickrPhotos = DataList::create( 'FlickrPhoto' )->where( 'Lat != 0 AND Lon !=0' );
if ( $flickrPhotos->count() == 0 ) {
return ''; // don't render a map
}
$map = $flickrPhotos->getRenderableMap();
$map->setZoom( $this->ZoomLevel );
$map->setAdditionalCSSClasses( 'fullWidthMap' );
$map->setShowInlineMapDivStyle( true );
@gordonbanderson
gordonbanderson / Example.php
Created April 3, 2013 07:36
Adding a colored line to a google map
$map->addLine( $point1, $point2, $colorHexCode );
@gordonbanderson
gordonbanderson / PageWithMap.php
Created April 3, 2013 07:30
Example of drawing a red/green/blue triangle around a given map coordinate
/*
Render a triangle around the provided lat,lon, zoom from the editing functions,
*/
public function MapWithLines() {
$map = $this->owner->getRenderableMap();
$map->setZoom( $this->ZoomLevel );
$map->setAdditionalCSSClasses( 'fullWidthMap' );
$map->setShowInlineMapDivStyle( true );
$scale = 0.3;