Skip to content

Instantly share code, notes, and snippets.

View perone's full-sized avatar
🙃

Christian S. Perone perone

🙃
View GitHub Profile
@perone
perone / plot.py
Last active June 5, 2020 19:49
Gist for the delay plot
# df_delay = Pandas dataframe with data
ax = df_delay.plot.scatter(
title='Symptom Onset vs Confirmation - COVID19 / Rio Grande do Sul / Brazil',
x='DATA_CONFIRMACAO',
y='DATA_SINTOMAS',
alpha=.4,
lw=0,
s=8,
c="Delay (days)",
@perone
perone / bayesian_enem.ipynb
Last active November 7, 2018 12:48
Análise bayesiana microdados enem
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@perone
perone / csvtable.py
Created December 7, 2012 18:48
reading csv table
>>> import pprint
>>> fh = open("alunos.txt")
>>> d = { v.split()[0]:v.split()[1:] for v in fh.readlines() }
>>> fh.close()
>>> pprint.pprint(d)
{'Beltrano': ['5.6', '7.8', '9.4', '5.3'],
'Fulano': ['8.3', '7.6', '9.5', '6.4'],
'Sicrano': ['5.6', '8.9', '7.4', '7.5']}
@perone
perone / pandas_table.py
Created December 5, 2012 23:27
pandas table
>>> frame = ps.read_table('alunos.txt', header=None, sep="\s*", index_col=0)
>>> frame.ix["Fulano"]
X1 8.3
X2 7.6
X3 9.5
X4 6.4
Name: Fulano
>>> frame.ix["Sicrano"]
X1 5.6
X2 8.9
@perone
perone / time_dict_value_max.py
Created December 4, 2012 00:31
Python max dict value
import timeit
t = timeit.Timer("v=sorted(d.items(), key=lambda x: x[1])[-1]",
"d = {'a': 1000, 'b': 3000, 'c':100}")
print t.timeit()
# 1.648s
t = timeit.Timer("v=max(d.iteritems(), key = operator.itemgetter(1))[0]",
"import operator; d = {'a': 1000, 'b': 3000, 'c':100}")
print t.timeit()
@perone
perone / gist:3860921
Created October 9, 2012 19:33
spf13-vim local
"" https://github.com/spf13/spf13-vim
colorscheme molokai
set tags=tags;/
nmap <F8> :TagbarToggle<CR>
""map <C-o> <C-T>
map <C-o> <C-]>
set mouse=
set nonumber
@perone
perone / gist:3837297
Created October 5, 2012 00:21
Scapy RTT
$~ sudo scapy
>>> from datetime import datetime
>>> pkt = IP(dst="www.google.com", ttl=1) / ICMP()
>>> ans,unans = sr(pkt*3)
Begin emission:
.**Finished to send 3 packets.
*
Received 4 packets, got 3 answers, remaining 0 packets
>>> sent = datetime.fromtimestamp(ans[0][0].sent_time)
@perone
perone / trends.py
Created September 18, 2012 19:47
Trends Twitter
@perone
perone / confpar.py
Created September 13, 2012 19:26
ConfigParser attrib
import ConfigParser
class AttrDict(dict):
def __getattr__(self, key):
d = AttrDict()
for k in self.keys():
if k.startswith(key):
dcoup = k[len(key)+1:]
if not dcoup:
return self[k]
@perone
perone / gist:3248889
Created August 3, 2012 15:47
Add one month
from dateutil.relativedelta import relativedelta
from datetime import datetime
now = datetime.now()
now_plus_one_month = now + relativedelta(months=1)