Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
from collections import namedtuple
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import shapefile as shp
def read_shape_file(*, file_path, encoding="ISO-8859-1"):
#!/usr/bin/env python
from collections import namedtuple
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import shapefile as shp
def read_shape_file(*, file_path, encoding="ISO-8859-1"):
#!/usr/bin/env python
import pandas as pd
import shapefile as shp
def read_shape_file(*, file_path, encoding="ISO-8859-1"):
"""Reads the shape file and specifies shp file encoding."""
return shp.Reader(file_path, encoding=encoding)
#!/usr/bin/env python
import shapefile as shp
def read_shape_file(*, file_path, encoding="ISO-8859-1"):
"""Reads the shape file and specifies shp file encoding."""
return shp.Reader(file_path, encoding=encoding)
def inspect_shape_file(*, shape_file):
@alfredo
alfredo / github-reflog.md
Last active December 8, 2017 14:34
Github reflog

Reflog-ish for Github (to recover a lost commit)

The following steps can be taken to recover a lost Github commit. e.g. An accidental push force removed the commits.

  1. Get a personal token with repo access from: https://github.com/settings/tokens Make sure the token has privileges to read/write the repository.

  2. Use the token to access the events history of the repo: The relevant key value in the JSON response is the sha:

$ curl -u {USERNAME}:{ACCESS_TOKEN} 'https://api.github.com/repos/{OWNER}/{REPOSITORY}/events?page=1'
@alfredo
alfredo / add.rs
Created November 28, 2017 11:10 — forked from steveklabnik/add.rs
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
@alfredo
alfredo / adb.bash
Last active March 23, 2017 13:34
adb record
alias adbrec='adb shell "screenrecord --bit-rate 8000000 --size 720x1280 /sdcard/vid.mp4"'
alias adbget='adb pull /sdcard/vid.mp4'
function adbrec () {
for i in "$@"
do
case $i in
-s=*|--size=*)
SIZE="${i#*=}"
shift # past argument=value
@alfredo
alfredo / git-report.sh
Last active March 28, 2017 08:41
Git report
# Commits only:
git log --since=1.days --format='%s' --no-merges | pbcopy
# Merges only
git log --since=1.days --format='%s' --merges | pbcopy
git log --since=1.days --format='%s' --no-merges --author=Alfredo
@alfredo
alfredo / script.py
Created April 28, 2016 12:28
script pattern
#!/usr/bin/env python
def do_something_complicated():
print "Done!"
if __name__ == "__main__":
do_something_complicated()
@alfredo
alfredo / .dir-locals.el
Last active January 22, 2016 11:04
emacs file to specify usage of tabs for an existing codebase using tabs
(
(javascript-mode . ((tab-width . 4)
(indent-tabs-mode . t)))
(python-mode . ((tab-width . 4)
(indent-tabs-mode . t)
(python-indent-offset . 4)
(flymake-python-pyflakes-extra-arguments . ("--ignore=W191"))))
)