Magic words:
psql -U postgresMost \d commands support additional param of __schema__.name__ and accept wildcards like *.*
\q: Quit/Exit\c __database__: Connect to a database\d __table__: Show table definition including triggers
| <!DOCTYPE html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
| <title>dynamic data in d3: data join & update-append-exit pattern</title> | |
| <meta name="description" content=""> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"><!-- Place favicon.ico and apple-touch-icon.png in the root directory --> |
| def fnx(arr): | |
| ''' | |
| pass in: NumPy 1d array | |
| returns: 3-tuple (idx_min_val, idx_max_val, max_diff) | |
| ''' | |
| arr = arr.reshape(-1, 1) | |
| arr_diff = arr.T - arr | |
| idx = NP.unravel_index(arr_diff.argmax(), arr_diff.shape) | |
| return (idx[0], idx[1], arr_diff[idx]) |
| >>> data = NP.arange(20) | |
| >>> data | |
| array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) | |
| # use floor division to account for an odd number of items in the array, | |
| # ie, 20//2 and 21//2 return the *same* result | |
| >>> mp = data.shape[0] // 2 | |
| ''' |
| ''' | |
| fizzbuzz refers to a quick test to filter applicants for programmer jobs who don't actually know how to code. | |
| (see eg, http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/) | |
| "pass in a sequence of integers from 1 to 100; | |
| for integers that are multiples of three: print “fizz” | |
| for integers that are multiples of five print “buzz” | |
| for integers that are multiples of five AND three print "fizzbuzz" | |
| for remaining integers, print the integer value | |
| ''' |
| import numpy as NP | |
| d = NP.random.randint(1, 10, 40).reshape(8, 5) | |
| mv = memoryview(d) | |
| def mem_addr(arr): | |
| ''' | |
| returns: location of a NumPy array in memory, or |
| package operator | |
| object FunctionalPipeline { | |
| class PipedObject[T] private[Functional] (value:T) | |
| { | |
| def |>[R] (f : T => R) = f(this.value) | |
| } | |
| implicit def toPiped[T] (value:T) = new PipedObject[T](value) | |
| } |
| #---------------- custom install Apache Spark -------------------# | |
| # instructions to build Apache Spark from source w/ current Scala & using sbt (vs maven) | |
| # download Apache Spark src from the appropriate mirror | |
| # untar: | |
| tar zxf spark-1.3.1.tgz |
| # Bulk convert shapefiles to geojson using ogr2ogr | |
| # For more information, see http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/ | |
| # Note: Assumes you're in a folder with one or more zip files containing shape files | |
| # and Outputs as geojson with the crs:84 SRS (for use on GitHub or elsewhere) | |
| #geojson conversion | |
| function shp2geojson() { | |
| ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp" | |
| } |
| #!/bin/bash | |
| #------------------------------------------------------------------------------ | |
| # Name: sbtmkdirs | |
| # Purpose: Create an SBT project directory structure with a few simple options. | |
| # Author: Alvin Alexander, http://alvinalexander.com | |
| # Info: http://alvinalexander.com/sbtmkdirs | |
| # License: Creative Commons Attribution-ShareAlike 2.5 Generic | |
| # http://creativecommons.org/licenses/by-sa/2.5/ | |
| #------------------------------------------------------------------------------ |
Magic words:
psql -U postgresMost \d commands support additional param of __schema__.name__ and accept wildcards like *.*
\q: Quit/Exit\c __database__: Connect to a database\d __table__: Show table definition including triggers