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 / composer.json
Last active September 11, 2024 13:35
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 / 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 / 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 / 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 / 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 / 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)
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 / 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',
@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 / 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")