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
@mfurlend
mfurlend / set field value to layer name
Created December 7, 2015 16:31
For ever layer, set every attribute field's value to the base file name of the layer. Useful for later aggregating by field value.
import arcpy
from arcpy import env
env.workspace = "E:/master_regions"
files = arcpy.ListFiles("*.dbf")
for file in files:
rows = arcpy.UpdateCursor(file)
for row in rows:
row.NAME = file.split('.')[0]
rows.updateRow(row)
@mfurlend
mfurlend / js-state-abbreviations
Created December 7, 2015 16:31
javascript state abbreviations to full name
state_abbr = {
'AL' : 'Alabama',
'AK' : 'Alaska',
'AS' : 'America Samoa',
'AZ' : 'Arizona',
'AR' : 'Arkansas',
'CA' : 'California',
'CO' : 'Colorado',
'CT' : 'Connecticut',
'DE' : 'Delaware',
Open Regedit, and navigate to this location: HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
Create a new KEY for the name of the executable, for example “Notepad.exe” (without the quotes).
In this new Key, create a new string value called “Debugger” without the quotes, and give it the value of the path to Notepad2. E.g. “c:\Program Files\Notepad 2\Notepad2.exe”
@mfurlend
mfurlend / set field value to layer name
Created December 7, 2015 16:29
For ever layer, set every attribute field's value to the base file name of the layer. Useful for later aggregating by field value.
import arcpy
from arcpy import env
env.workspace = "E:/master_regions"
files = arcpy.ListFiles("*.dbf")
for file in files:
rows = arcpy.UpdateCursor(file)
for row in rows:
row.NAME = file.split('.')[0]
rows.updateRow(row)
@mfurlend
mfurlend / rename to parent
Created December 7, 2015 16:29
recursively rename base name of files to parent folder's name (bash)
#!/bin/bash
for dir in *; do
if test -d "$dir"; then
(
cd $dir
for file in *; do
newfile=$dir.${file#*.}
mv "$file" "$newfile"
done
@mfurlend
mfurlend / fix_sendmail_permissions
Last active December 7, 2015 16:26
Fix "Permission denied" when attempting to use sendmail (Centos) From https://access.redhat.com/articles/1763
chown root.smmsp /usr/sbin/sendmail.sendmail
chmod g+s /usr/sbin/sendmail.sendmail
chown smmsp.smmsp /var/spool/clientmqueue
@mfurlend
mfurlend / git_branch_from_changes.md
Last active November 20, 2015 20:40
Create a git branch from (un?)committed changes

If you hadn't made any commit yet, only (1: branch) and (3: checkout) would be enough.
Or, in one command: git checkout -b newBranch.

As mentioned in the [git reset man page][1]:

1. $ git branch topic/wip    
2. $ git reset --soft HEAD~3 
     (or --hard to remove unindexed files) 
2. $ git checkout topic/wip
@mfurlend
mfurlend / bootstrap viewport helper
Last active October 2, 2015 17:34
Display your current viewport (xs, sm, md or lg) context when using Bootstrap
/*Detect Your Current Viewport Context
This small CSS snippet will display your current viewport (xs, sm, md or lg) context when using Bootstrap. It can be useful for testing responsive sites, or demoing responsive behaviors on different viewports. Hope it helps someone out there!
*/
body::before {
content: "xs";
position: fixed;
top: 0;
left: 0;
z-index: 9999999;
background-color: #000;
@mfurlend
mfurlend / composer.json
Last active April 18, 2024 21:41
composer require git repository
{
"name": "my_vendor_name/my_package",
"description": "My Package Description",
"license": "GPL-3.0",
"autoload": {
"classmap": [ // search these directories for classes
"lib/"
]
},
"repositories": {
@mfurlend
mfurlend / xsl.xsl
Last active August 29, 2015 14:16
XSLT for parsing dwml from forecast.weather.gov
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>