Skip to content

Instantly share code, notes, and snippets.

View mfurlend's full-sized avatar

Mikhail Furlender mfurlend

  • WeatherBELL Analytics
  • New York, NY
View GitHub Profile
Last command's parameters: !* TAB
Last command's first parameter: !^ TAB
Last command's last parameter: !$ TAB
@mfurlend
mfurlend / Bash - Special Variables.md
Created January 5, 2017 16:40
Bash - Special Variables
  • $1, $2, $3, ... are the [positional parameters][1].
  • "$@" is an array-like construct of all positional parameters, {$1, $2, $3 ...}.
  • "$*" is the IFS expansion of all positional parameters, $1 $2 $3 ....
  • $# is the number of positional parameters.
  • $- current options set for the shell.
  • $$ pid of the current shell (not subshell).
  • $_ most recent parameter (or the abs path of the command to start the current shell immediately after startup).
  • $IFS is the (input) field separator.
  • $? is the most recent foreground pipeline exit status.
  • $! is the PID of the most recent background command.
@mfurlend
mfurlend / Difference between EPSG 4326 & 3857
Created November 21, 2016 00:33 — forked from keum/Difference between EPSG 4326 & 3857
EPSG 4326 and EPSG 3857 of Web Mercator
EPSG: 4326 uses a coordinate system on the surface of a sphere or ellipsoid of reference.
WGS 84 - Earth as Geoid. -Mercator
EPSG: 3857 uses a coordinate system PROJECTED from the surface of the
sphere. Earth as perfectly sphere. -Web Mercator
Think of it as this way:
EPSG 4326 uses a coordinate system the same as a GLOBE (curved surface).
EPSG 3857 uses a coordinate system the same as a MAP (flat surface).

###export bounding box for reuse export LON1=-74.259094 export LAT1=40.477398 export LON2=-73.700165 export LAT2=40.91758

###mapbbox.js outputs a .png image using the Web Mercator (EPSG: 3857) projection

./mapbbox.js -h 480 -w 640 \                           #dimensions of output image (px)

-b $LON1,$LAT1,$LON2,$LAT2 \ #bounds: lon1,lat1,lon2,lat2

find replace
isset *\( *(\$(?:_?)?(?:\w*)) *\[ ?([\w'"\$]*) *\] *\) array_key_exists($2,$1)
ex:
isset($_SERVER['something'])		=>	 array_key_exists('something',$_SERVER)
isset( $_SERVER['something'])		=>	 array_key_exists('something',$_SERVER)
isset( $_SERVER['something' ])		=>	 array_key_exists('something',$_SERVER)
isset( $_SERVER  ['something' ] )	=>	 array_key_exists('something',$_SERVER)
isset($_SERVER['some_1_Thing1'])	=> array_key_exists('some_1_Thing1',$_SERVER)
@mfurlend
mfurlend / jquery.swapClass.js
Created July 5, 2016 23:42
Swap the two classes in the selector
$.fn.swapClass = function(a, b) {
if (a && b) {
this.toggleClass(a).toggleClass(b);
} else {
let arr = this.selector.split(',');
if (arr.length < 2) {
return this;
}
return this.swapClass(arr[0].substr(1), arr[1].substr(1));
}
@mfurlend
mfurlend / gist:bdb2f8050cf0976e302b
Created March 28, 2016 17:09
Bootstrap 3 responsive breakpoints
@media(max-width:767px){}
@media(min-width:768px){}
@media(min-width:992px){}
@media(min-width:1200px){}
@mfurlend
mfurlend / share_with.sh
Created January 6, 2016 19:55
A convenience wrapper around setfacl to facilitate sharing a file or directory with a user or group.
# A convenience wrapper around setfacl to facilitate sharing a file or directory with a user or group.
# ex:
# $ getfacl ~/test_directory
# file: /root/test_directory
# owner: root
# group: root
# user::rwx
# group::r-x
# other::r-x
#
@mfurlend
mfurlend / $shapefile=>array(fieldNames)
Created December 7, 2015 16:31
arcGIS shape filename -> array of field names as PHP array
import arcpy
import json
from arcpy import env
env.workspace = "E:/master_regions_unpacked"
txtFile = open("E:/master_regions/regionArray","w")
txt = []
files = arcpy.ListFiles("*.dbf")
for file in files:
txt.append("'"+str(file).split(".")[0]+"'=>array(")
@mfurlend
mfurlend / gist:d139e71d7b119c581922
Created December 7, 2015 16:31
add field to each layer
import arcpy
from arcpy import env
env.workspace="E:\master_regions_unpacked"
files = arcpy.ListFiles("*.dbf")
for file in files:
arcpy.AddField_management(file, "CODE", "TEXT")