Skip to content

Instantly share code, notes, and snippets.

View dlebauer's full-sized avatar
😀

David LeBauer dlebauer

😀
View GitHub Profile
@dlebauer
dlebauer / latex_demo.tex
Created November 2, 2011 19:58
A demonstration file for use with testing / debugging latex documents. Uses lipsum for demo text and [demo] option to the graphicx package
\documentclass{article}
\usepackage{caption}% http://ctan.org/pkg/caption
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage[demo]{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\tableofcontents
\section{First section}
\lipsum[1]
\begin{figure}[p]
\centering \includegraphics{image1}
@dlebauer
dlebauer / zenburn.el
Created December 16, 2011 16:54
zenburn color theme for emacs
;;; zenburn.el --- A low contrast colour theme for Emacs
;; Copyright (C) 2011 Bozhidar Batsov
;; Author: Bozhidar Batsov <bozhidar.batsov [at] gmail.com>
;; Keywords: color, theme, zenburn
;; X-URL: http://github.com/bbatsov/zenburn-emacs
;; URL: http://github.com/bbatsov/zenburn-emacs
;; EmacsWiki: ColorThemeZenburn
;; Version: 0.1
[1] "{\"site_0_data\":[{\"name\":\"Tropical Forest\",\"S_CO2\":3077.19440798194,\"S_CH4\":8.71414987655346,\"S_N2O\":221.440495767305,\"F_CO2\":-777.589630035838,\"F_CH4\":198.153276609512,\"F_N2O\":9.21042004738499,\"D_CO2\":0,\"D_CH4\":0,\"D_N2O\":0},{\"name\":\"Misty Mountain Top\",\"S_CO2\":715.481930448906,\"S_CH4\":18.5897095138668,\"S_N2O\":11.2808552885403,\"F_CO2\":-264.088404311696,\"F_CH4\":-4.53053004775435,\"F_N2O\":43.9477537844218,\"D_CO2\":0,\"D_CH4\":0,\"D_N2O\":0}],\"site_1_data\":[{\"name\":\"Temperate Forest\",\"S_CO2\":4.56309041699992,\"S_CH4\":0.0587650836752113,\"S_N2O\":0.0181995344292526,\"F_CO2\":-463.068959358755,\"F_CH4\":-4.53053004775435,\"F_N2O\":29.7798338969974,\"D_CO2\":0,\"D_CH4\":0,\"D_N2O\":0},{\"name\":\"Misty Mountain Hop\",\"S_CO2\":271.104915549568,\"S_CH4\":2.34182957152679,\"S_N2O\":2.55419110417906,\"F_CO2\":-247.868281691267,\"F_CH4\":-3.7982437401118,\"F_N2O\":6.74989211681713,\"D_CO2\":0,\"D_CH4\":0,\"D_N2O\":0}]}
@dlebauer
dlebauer / r46.f90
Created March 7, 2013 02:42
diffs of ED2IN files: diff -wu <(grep -v [[:space:]]*! web/template/ED2.2_r82) <(grep -v [[:space:]]*! models/ed/inst/ED2IN.r82); diff -w <(grep -v [[:space:]]*! web/template/ED2.2_r46) <(grep -v [[:space:]]*! models/ed/inst/ED2IN.r46)
--- /dev/fd/63 2013-03-06 20:42:02.260732155 -0600
+++ /dev/fd/62 2013-03-06 20:42:02.260732155 -0600
@@ -3,68 +3,122 @@
+ NL%IMONTHZ = @END_MONTH@
+ NL%IDATEZ = @END_DAY@
+ NL%IYEARZ = @END_YEAR@
+
@dlebauer
dlebauer / gist:5390548
Created April 15, 2013 19:12
Queries for yieldsview and traitsview from BETYdb
drop view if exists yieldsview;
create view yieldsview as select yields.id as yield_id, yields.citation_id, yields.site_id, yields.treatment_id, sites.sitename as site, sites.city, sites.lat, sites.lon, species.scientificname, species.genus, citations.author as author, citations.year as cityear, treatments.name as trt, date, month(date) as month, year(date) as year, mean, n, statname, stat, yields.notes, users.name as user, planting, seeding from yields left join sites on yields.site_id = sites.id left join species on yields.specie_id = species.id left join citations on yields.citation_id = citations.id left join treatments on yields.treatment_id = treatments.id left join users on yields.user_id = users.id left join mgmtview on yields.id = mgmtview.yield_id;
drop view if exists traitsview;
create view traitsview as select traits.id as trait_id, traits.citation_id, traits.site_id, traits.treatment_id, sites.sitename as site, sites.city, sites.lat, sites.lon, species.scientificname, species.genus, citations.a
lat lon gdd
44.41666667 11.46666667 1878
40.15 16.63333333 2188
40.15 16.63333333 1526
38.36666667 23.16666667 2496
38.21666667 -78.11666667 1813
35.71666667 -78.66666667 2215
37.61666667 -79.95 1464
37.18333333 -80.41666667 1414
35.88333333 -82.05 2049
site_id lat lon temp
1 38.37 23.17 26.4269701086956
1 38.37 23.17 26.0835597826087
1 38.37 23.17 26.1279891304347
1 38.37 23.17 26.3497282608695
1 38.37 23.17 25.8631114130434
3 44.42 11.47 21.4891304347826
3 44.42 11.47 24.7163994565217
9 41.25 -96.67 23.8012228260869
10 34.3 109.1 23.4675951086956
sites_a <- structure(list(site_id = c(1L, 3L, 6L, 9L, 10L, 11L, 12L, 13L,
15L, 17L, 18L, 20L, 25L, 26L, 27L, 28L, 29L, 31L, 32L, 35L, 36L,
37L, 39L, 40L, 42L, 44L, 47L, 52L, 54L, 55L, 56L, 57L, 58L, 59L,
60L, 63L, 64L, 65L, 70L, 71L, 72L, 73L, 75L, 76L, 77L, 78L, 79L,
80L, 83L, 84L, 85L, 87L, 90L, 91L, 92L, 93L, 94L, 96L, 97L, 98L,
99L, 100L, 101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L,
110L, 111L, 112L, 113L, 114L, 115L, 116L, 117L, 119L, 120L, 121L,
122L, 123L, 124L, 125L, 126L, 128L, 129L, 130L, 131L, 132L, 133L,
135L, 136L, 137L, 138L, 139L, 140L, 141L), sitename = c("Aliartos ",
"Bologna ", "Brookings SD", "Ithaca NE", "Shaanxi ", "South Shore SD",
/* required styles */
.leaflet-map-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
.leaflet-marker-pane,
### this works
SELECT cartodb_id, ST_GeomFromText(replace(replace(replace(replace(replace(geometry, '<Polygon><outerBoundaryIs><LinearRing><coordinates>', 'Linestring('), '</coordinates></LinearRing></outerBoundaryIs></Polygon>', ')'), ',', '$'), ' ', ','), '$', ' '),4326) geom FROM test_yield_county
### the official query
delete FROM test_yield_county where geometry = ''
with f as (SELECT cartodb_id, ST_GeomFromText(replace(replace(replace(replace(replace(geometry, '<Polygon><outerBoundaryIs><LinearRing><coordinates>', 'Linestring('), '</coordinates></LinearRing></outerBoundaryIs></Polygon>', ')'), ',', '$'), ' ', ','), '$', ' '),4326) geom FROM test_yield_county order by geometry desc)
update test_yield_county d
set the_geom = (