Skip to content

Instantly share code, notes, and snippets.

View ddd1600's full-sized avatar

David Douglas ddd1600

  • Murrells Inlet, SC
View GitHub Profile
@ddd1600
ddd1600 / zip_individual_files.rb
Last active February 27, 2018 20:16
zip individual files inside of folder
require 'shellwords'
require 'highline/import'
target_ext = ask("file extension to target (excluding the period)?")
output_ext = ask("output file extension? press enter to default to zip")
output_ext = output_ext.blank? ? "zip" : output_ext
files = Dir.glob("*.#{target_file_extension}")
files.each do |f|
where("st_intersects(proj_shape_4326, ST_GeomFromText('#{shp.as_text}',4326))")
@ddd1600
ddd1600 / index.html
Last active April 12, 2016 20:30
gist of code being displayed in browser -- created for stackoverflow question here:
<!DOCTYPE html>
<html>
<head>
<title>Construction Monitor</title>
<link data-turbolinks-track="true" href="/assets/application.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/bootstrap_and_overrides.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/draws.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/property.css?body=1" media="all" rel="stylesheet" />
<script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
@ddd1600
ddd1600 / active_record_json_dump_and_restore_monkeypatch.rb
Last active March 15, 2016 23:58
patch that adds two methods, dump_json and read_json to any active record model as class methods. Very useful for restoring databases onto production servers, for example.
class ActiveRecord::Base
def self.dump_json(sql="")
records = sql.blank? ? all : where(sql)
`touch #{self}_backup.json`
File.open(File.join(Rails.root, "#{self}_backup.json"), 'w') do |f|
f.write(records.to_json)
end
end
@ddd1600
ddd1600 / gist:6c6b52bde3e7bfd95c59
Created January 21, 2016 22:04
google earth crash error message on el capitan (after loading shapefile)
Process: Google Earth [17592]
Path: /Applications/Google Earth Pro.app/Contents/MacOS/Google Earth
Identifier: com.Google.GoogleEarthPro
Version: 7.1 (7.1.5.1557)
Code Type: X86 (Native)
Parent Process: ??? [1]
Responsible: Google Earth [17592]
User ID: 502
Date/Time: 2016-01-21 16:45:50.411 -0500
@ddd1600
ddd1600 / costar_vrt.vrt
Created January 18, 2016 21:54
costar_vrt.vrt
<OGRVRTDataSource>
<OGRVRTLayer name="costar_data">
<SrcDataSource>costar_data.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>
</OGRVRTLayer>
</OGRVRTDataSource>
@ddd1600
ddd1600 / convert_costar_export_to_kml.rb
Last active January 18, 2016 21:39
script that takes the latest csv export of costar data in the downloads directory, converts to kml, and opens. see costar_vrt.vrt for the file necessary here. Must be hard-coded to to work in a different path.
latest_download = Dir.glob("/Users/daviddouglas/Downloads/Export*.csv").max do |a,b|
File.ctime(a) <=> File.ctime(b)
end
puts "latest download is #{latest_download}"
`cp #{latest_download} /Users/daviddouglas/sikuli_scripts`
basename = File.basename(latest_download)
`mv #{basename} costar_data.csv`
`ogr2ogr -f KML costar_data.kml costar_vrt.vrt`
`open costar_data.kml`
`say "save the KML somewhere else to prevent from being overwritten"`
@ddd1600
ddd1600 / georeference_buddy.rb
Last active January 8, 2016 18:25
geoference plugin helper
require 'geocoder'
require 'highline/import'
puts "to use this tool again after running, run `GeoreferencerBuddy.go`.\nto use just the lat/lng plucker, there is also a class method called `pluck`"
#
#this tool is best if added as an alias to .bash_profile or equivalent.
#example:
#alias georeference='ruby /Users/davo/helpers/georeference_buddy.rb'
#alias geo='georeference'
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//Key message
char msgs[5][15] = {"Right Key OK ",
"Up Key OK ",
"Down Key OK ",
"Left Key OK ",
"Select Key OK" };
@ddd1600
ddd1600 / postgresql-postgis-ubuntu-installation-tutorial-2012
Created January 13, 2015 00:39
postgresql/postgis installation tutorial for ubuntu installations
I used this tutorial on January 12 to setup my ubuntu server gis situation.
-----------
LoginHelp/GuideAbout TracPreferences
WikiTimelineRoadmapBrowse SourceView TicketsSearch
Start PageIndexHistoryLast Change
How to Get Started with PostGIS 2.0 on Ubuntu 12.04 (precise)
(minor updates as of 12/18/12) (This installation may generate some errors related to jvm - please see: http://www.jaloonz.com/2012/08/installing-postgis-201-on-ubuntu-1204.html if you run into any problems.)