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 / 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 / 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 / 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
<?php
class Grocery extends DataObject {
private static $db = array(
'Name' => 'Varchar(255)',
'Price' => 'Int'
);
private static $belongs_many_many = array(
'GroceryPages' => 'GroceryPage'
@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 || {};
/**
@gordonbanderson
gordonbanderson / Aggregation.php
Created August 8, 2015 15:14
Example of how to aggregate with filtering using Elastica
$queryString = new QueryString($_GET['q']);
$isoTerm = new Term();
$isoTerm->setTerm('ISO',4000);
$apeterm = new Term();
$apeterm->setTerm('Aperture',2.7);
$andFilter = new BoolAnd();
$andFilter->addFilter($apeterm);
ExpiresActive On
Options FollowSymLinks MultiViews
#Do these from rails explicity
#ExpiresByType text/html "access plus 1 minute"
#Do this from Apache
ExpiresByType text/css "access plus 1 year"
@gordonbanderson
gordonbanderson / grabss
Created September 11, 2015 06:01
Transfer latest screenshots from Kodi box - note use ssh config to make 'ssh kodi' work to your username/IP requirements
#!/usr/bin/ruby
nfiles = ARGV[0]
puts "Transferring latest #{nfiles} screenshots to current directory"
cmd="ssh kodi <<'ENDSSH'
ls -t ~/Pictures/*.png | head -n #{nfiles}
ENDSSH"
files = `#{cmd}`
for file in files.lines
@gordonbanderson
gordonbanderson / ClearElasticFieldCacheExtension.php
Created September 16, 2015 09:56
How to hook into /dev/build using SilverStripe and Extensions
<?php
class ClearElasticFieldCacheExtension extends Extension {
public function onAfterInit() {
$cache = SS_Cache::factory('whatever');
$cache->clean();
}
}
@gordonbanderson
gordonbanderson / capbyara_screenshot_google.rb
Created June 28, 2011 02:29
Use capybara to screenshot google home page outside of Rails
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'yaml'
Capybara.run_server = false
Capybara.current_driver = :selenium