Skip to content

Instantly share code, notes, and snippets.

@chrisjacob
chrisjacob / README.md
Created February 18, 2011 03:44
Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Intro

Description: Setup GitHub Pages "gh-pages" branch and "master" branch as subfolders of a parent project folder ("grandmaster").

Author: Chris Jacob @_chrisjacob

Tutorial (Gist): https://gist.github.com/833223

The Result

@akavel
akavel / HOWTO TortoiseHg and Github .markdown
Created January 6, 2012 02:35
TortoiseHg and GitHub.com

Read-only access, in short

First,

hg clone http://bitbucket.org/durin42/hg-git HGGIT_PATH

Second, in "mercurial.ini" add:

[extensions]
hggit=HGGIT_PATH\hggit
@sevas
sevas / gist:1605251
Created January 13, 2012 09:17
set french locale on windows with python
# locale string from: http://msdn.microsoft.com/en-us/library/cdax410z(v=VS.80).aspx
if sys.platform in [ 'win32']:
locale.setlocale(locale.LC_ALL, 'fra')
@trongthanh
trongthanh / gist:2779392
Last active April 24, 2024 23:46
How to move a folder from one repo to another and keep its commit history
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@jasonbot
jasonbot / rowsasdicts.py
Last active January 31, 2019 20:41
Get dicts instead of lists from an arcpy.da SearchCursor
def rows_as_dicts(cursor):
colnames = cursor.fields
for row in cursor:
yield dict(zip(colnames, row))
with arcpy.da.SearchCursor(r'c:\data\world.gdb\world_cities', '*') as sc:
for row in rows_as_dicts(sc):
print row['CITY_NAME']
@jasonbot
jasonbot / rowsasnamedtuples.py
Created July 12, 2012 19:37
Get namedtuples instead of lists from an arcpy.da SearchCursor
import collections
def rows_as_namedtuples(cursor):
col_tuple = collections.namedtuple('Row', cursor.fields)
for row in cursor:
yield col_tuple(*row)
with arcpy.da.SearchCursor(r'c:\data\world.gdb\world_cities', '*') as sc:
for row in rows_as_namedtuples(sc):
print sc.CITY_NAME
@maphew
maphew / install-pip.py
Last active December 16, 2015 06:49
A pure python script to download and install the distribute_setup and pip utilities. Tested on Windows 7, Python 3.2.
"""
pip-install.py
A pure python script to download and install the distribute_setup and
pip utilities
Adapted from:
http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows/15294806#15294806
http://stackoverflow.com/questions/2792650/python3-error-import-error-no-module-name-urllib
http://stackoverflow.com/questions/1093322/how-do-i-check-what-version-of-python-is-running-my-script
@maphew
maphew / push_to_gist.py
Last active April 19, 2020 16:34 — forked from anonymous/push_to_Gist.txt
=== Leo editor script to publish from a node to Gist === At present everything is done anonymously, so there's no way to delete an old push, or make the next a push a revision to a previous one. In other words it's trivial to create **many** duplicates. So I wouldn't actually use this yet; it's just proof of concept (and wickedly easy!).
import requests
import json
description = "published from Leo" # todo: derive from docstring, if present, otherwise 1st para
public = True
filename = p.h # node headline
content = p.b # node body
api_url = 'https://api.github.com/gists'
@maphew
maphew / Run Elevated.xml
Last active December 18, 2015 05:39
An experimental Leo button which executes the currently selected node as a python script after invoking User Account Control (UAC). Not fully functional yet -- and dangerous. You could easily bork all your data or even your computer with this: it runs code with admin privileges, no sanity checking, and very limited feedback. Tracebacks etc. are …
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo (http://webpages.charter.net/edreamleo/front.html) -->
<?xml-stylesheet ekr_test?>
<leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >
<leo_header file_format="2"/>
<vnodes>
<v t="maphew.20130607222534.1739" a="E"><vh>@button Run Elevated</vh>
<v t="maphew.20130608014320.1983"><vh>docstring</vh></v>
<v t="maphew.20130608014320.1743"><vh>imports</vh></v>
<v t="maphew.20130608014320.1744"><vh>Leo preparation</vh></v>
@oevans
oevans / AGO_PullHostedFeatures.py
Last active April 16, 2024 18:37
Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe below.
import os, urllib, urllib2, datetime, arcpy, json
## ============================================================================== ##
## function to update a field - basically converts longs to dates for date fields ##
## since json has dates as a long (milliseconds since unix epoch) and geodb wants ##
## a proper date, not a long.
## ============================================================================== ##
def updateValue(row,field_to_update,value):
outputfield=next((f for f in fields if f.name ==field_to_update),None) #find the output field