Skip to content

Instantly share code, notes, and snippets.

View fccoelho's full-sized avatar
🏠
Working from home

Flávio Codeço Coelho fccoelho

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python
# coding: utf-8
# # Exercícios
# In[11]:
import pandas as pd
get_ipython().run_line_magic('pylab', 'inline')
@fccoelho
fccoelho / openapi.json
Created September 15, 2019 19:13
openApi
{"openapi": "3.0.0", "servers": [{"url": "http://localhost:8080"}], "info": {"title": "Hathor API", "version": "0.16.0-beta"}, "consumes": ["application/json"], "produces": ["application/json"], "paths": {"/p2p/peers": {"x-visibility": "private", "post": {"tags": ["p2p"], "operationId": "p2p_peers", "summary": "Add p2p peers", "description": "Connect to the given peers", "requestBody": {"description": "Peers you want to connect to", "required": true, "content": {"application/json": {"schema": {"type": "array", "description": "List of peers to connect in the format \"protocol:host:port\"", "items": {"type": "string"}}, "examples": {"peer_list": {"summary": "List of peers", "value": ["tcp:localhost:8000", "tcp:17.24.137.234:40403"]}}}}}, "responses": {"200": {"description": "The peers we connected to (we don't try connecting to already known peers)", "content": {"application/json": {"examples": {"success": {"summary": "Peers added", "value": {"success": true, "peers": ["tcp:localhost:8000", "tcp:17.24.137.234:4
@fccoelho
fccoelho / app.py
Last active September 9, 2019 20:56
Dash app with maps and plotly express
from flask import Flask
import plotly_express as px
import pandas as pd
import geopandas as gp
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
@fccoelho
fccoelho / cgibbs.pyx
Created December 28, 2010 09:37
Comparison of MCMC implementations in Python and Cython. This is discussed here: http://pyinsci.blogspot.com/2010/12/efficcient-mcmc-in-python.html
'''
Pure cython version
compile with:
$ cython cgibbs.pyx
$ gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.6 -o cgibbs.so cgibbs.c
then import from python shell and call main()
'''
import random,math, time
@fccoelho
fccoelho / README
Created September 21, 2011 17:26 — forked from uiltondutra/gist:231960
MongoDB init script for a sharding node.
To install this init script, you should save mongodb to /etc/init.d/ and mongosharding.conf to /etc/
then run the following commands as root or with sudo:
chmod 755 /etc/init.d/mongodb
chown root:root /etc/init.d mongodb
update-rc.d mongodb defaults
This installation procedure was tested on UBUNTU 11.10
@fccoelho
fccoelho / fwf.csv
Created June 13, 2016 12:48
Pandas FWF bug
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
12 13 5 0 11AVENIDA GOVERNADOR EDMUNDO PINTO 72 ACRELANDIA 01 00100169945000
12 13 5 0 11AVENIDA GOVERNADOR EDMUNDO PINTO 72 ACRELANDIA
@fccoelho
fccoelho / cgillespie.pyx
Created February 14, 2013 22:41
Cython based Gillespie algorithm
from numpy.random import uniform, multinomial, exponential
#from numpy import arange, array, empty,zeros
import numpy as np
cimport numpy as np
import time
from random import random
DTYPE = np.double
ctypedef np.double_t DTYPE_t
ctypedef np.int_t INT_t
@fccoelho
fccoelho / choropleth.js
Created November 27, 2012 23:09
D3.js map choroplethmap
<script src="/js/d3.v2.js"></script>
<link type="text/css" rel="stylesheet" href="/css/colorbrewer/colorbrewer.css">
<style type="text/css">
svg {
background: #eee;
width: 960px;
height: 500px;
}
#polygons path {
stroke: #fff;
@fccoelho
fccoelho / test_virtualenvmagic.py
Created June 5, 2012 11:04 — forked from minrk/shebang.py
Prototype of an extension to provide acess to virtual python environment on an IPython notebook cell
# -*- coding: utf-8 -*-
"""
Tests for the virtualenvmagic extension
Author: Flávio Codeço Coelho - @fccoelho
"""
import os
import nose.tools as nt
@fccoelho
fccoelho / mongodb-upstart.sh
Created March 8, 2012 13:45 — forked from onedesign/mongodb-upstart.sh
Ubuntu upstart script for MongoDB with automatic repair
# Ubuntu upstart file at /etc/init/mongodb.conf
pre-start script
mkdir -p /var/lib/mongodb/
mkdir -p /var/log/mongodb/
end script
start on runlevel [2345]
stop on runlevel [06]