Skip to content

Instantly share code, notes, and snippets.

View dwcoates's full-sized avatar

Dodge Coates dwcoates

  • Chess.com
  • New York, NY
View GitHub Profile
@dwcoates
dwcoates / parsing_json_2.py
Created February 14, 2017 06:19
Second snippet for you
# option 1
import gzip
fp = gzip.open('foo.gz')
x = json.load(fp.read())
# option 2
gzip.open('file.gz', 'rt', encoding='utf-8')
# rest at www.github.com/dwcoates/yelp-reviews/preprocess.py
import gzip
fp = gzip.open('foo.gz')
contents = fp.read() # contents now has the uncompressed bytes of foo.gz
fp.close()
u_str = contents.decode('utf-8') # u_str is now a unicode string
lines = u_str.split('\n')
for line in lines:
j = json.loads(line)

(defun my-kill-thing-at-point (thing) “Kill the `thing-at-point’ for the specified kind of THING.” (let ((bounds (bounds-of-thing-at-point thing))) (if bounds (kill-region (car bounds) (cdr bounds)) (error “No %s at point” thing))))

(defun my-kill-word-at-point () “Kill the word at point.” (interactive)