This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://geospatialpython.com/ | |
import json, pymongo, shapefile | |
from json import dumps | |
database = 'geo' | |
connection = pymongo.MongoClient() | |
db = getattr(connection,database) | |
def renamesh2json(x): | |
d = x.split(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"log" | |
"net" | |
core "github.com/ipfs/go-ipfs/core" | |
corerepo "github.com/ipfs/go-ipfs/core/corerepo" | |
coreunix "github.com/ipfs/go-ipfs/core/coreunix" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from http://ask.metafilter.com/255675/Decoding-cancer-addled-ramblings | |
sed 's/\B\w*//g;s/\s//g' full_file.txt > acronym_file.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# navigation | |
C-a # beginning of line | |
C-e # end of line | |
M-> # eof | |
M-< # head of file | |
M-g g 100 # goto line 100 | |
# general | |
C-h f thing-name # describe a function named thing-name | |
M-x load-library RET icicles RET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# In addition, the use of mutable objects as default values may lead to unintended behavior: | |
def foo(x, items=[]): | |
items.append(x) | |
return items | |
foo(1) # returns [1] | |
foo(2) # returns [1, 2] | |
foo(3) # returns [1, 2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# all straight from here: | |
# https://github.com/daviddrysdale/python-phonenumbers | |
import phonenumbers | |
def numberizer(num): | |
z = phonenumbers.parse(num,"US") | |
return(phonenumbers.format_number(z,phonenumbers.PhoneNumberFormat.NATIONAL)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def argmax(arg, X): | |
""" | |
>>> zee = [{"cool":{"stuff":1,"things":0.5}},{"cool":{"stuff":2,"things":0.25}}] | |
>>> argmax("cool.stuff",zee) | |
{'cool': {'things': 0.25, 'stuff': 2}} | |
>>> argmax("cool.things",zee) | |
{'cool': {'things': 0.5, 'stuff': 1}} | |
""" | |
ranked = sorted(X, key=lambda x: -getByDot(x,arg)) | |
leader = filter(lambda x: getByDot(x,arg) == reduce(max,[getByDot(r, arg) for r in ranked]),ranked)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
###################################### | |
#### THIS IS IMPORTANT EVERYWHERE #### | |
import sys # | |
reload(sys) # | |
sys.setdefaultencoding("UTF-8") # | |
#sys.getdefaultencoding() # | |
###################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git commit | |
mittenchops/differentreponame#issuenumberindifferentreponame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git commit --amend | |
# git push --force # <-- WARNING, HOPEFULLY YOU DON'T HAVE TO DO THIS PART. |
NewerOlder