Skip to content

Instantly share code, notes, and snippets.

View macoj's full-sized avatar

Marcos Oliveira macoj

View GitHub Profile
@macoj
macoj / stroke_same_as_fill.py
Last active August 29, 2015 14:26
(python) Creates a new QML file (QGIS style format) with the colors of the strokes equals to the shape fills.
import re
def stroke_same_as_fill(file_name, output_file_name):
"""
Creates a new QML file (QGIS style format) with the colors of the strokes equals to the shape fills.
stroke_same_as_fill("/home/marcos/Downloads/teste.qml", "/home/marcos/Downloads/teste2.qml")
:param file_name: filename of QML input file
:param output_file_name: output
"""
with open(file_name, 'r') as input_file, open(output_file_name, 'w') as output_file:
lines = input_file.readlines()
@macoj
macoj / git_rm_dir.sh
Created August 1, 2015 22:57
removes dir from git and never adds again
git rm --cached -r .idea
@macoj
macoj / git.sh
Last active August 29, 2015 14:27
git-related command
git config --global url."https://[email protected]".insteadOf "https://github.com"
git config --global credential.helper 'cache --timeout=28800'
git config remote.origin.url https://{USERNAME}:{PASSWORD}@github.com/{USERNAME}/{REPONAME}.git
git config -l
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"
@macoj
macoj / links_color.tex
Created August 12, 2015 19:03
setting the color of the references
@macoj
macoj / hello_twitter.py
Last active October 10, 2017 23:43
Just a hello to Twitter API
"""
this code is here: http://tinyurl.com/hello-network
Twitter libraries:
https://dev.twitter.com/overview/api/twitter-libraries
Twitter Python library:
https://github.com/sixohsix/twitter
$ sudo pip2.7 install twitter
@macoj
macoj / encode.py
Created December 7, 2015 17:06
dirty fix to quickly print names with different encodes
print name.encode('ascii', 'ignore')
print name.encode('utf-8', 'ignore')
@macoj
macoj / get_projection.py
Created May 25, 2016 14:20
trying to get the projection of a shapefile
from osgeo import ogr, osr
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(r'tabblock2010_25_pophu.shp')
# from Layer
layer = dataset.GetLayer()
spatialRef = layer.GetSpatialRef()
print spatialRef
# from Geometry
feature = layer.GetNextFeature()
geom = feature.GetGeometryRef()
@macoj
macoj / howto.md
Last active September 18, 2016 22:32
how to merge many points of a scatterplot made with matplotlib

Approach A

  1. Export the plot as SVG
   plt.savefig("plot.svg")
  1. Open plot.svg with an editor and include in the definitions the following:
<defs>
   <filter id="shadow">
      <feOffset dx="0" dy="0"/>
@macoj
macoj / guerry_balbi_quetelet.bibtex
Last active October 28, 2016 14:47
bibtex for old criminology literature: Guerry, Balbi, and Quetelet. (adapted from: http://www.datavis.ca/gallery/guerry/)
@BOOK{quetelet1833recherches,
address = {Brussels, Belgium},
author = {Quetelet, A},
pages = {87},
publisher = {M. Hayez},
title = {{Recherches sur le penchant au crime aux diff{\'{e}}rens {\^{a}}ges}},
url = {https://books.google.com/books?id=ZNEiAAAAMAAJ},
year = {1833}
}
@macoj
macoj / symbols.tex
Created November 22, 2016 15:48
symbols of all types in latex
%http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf
\usepackage{latexsym} % needs this to have on latex2e
$\bullet$