Skip to content

Instantly share code, notes, and snippets.

View brun0xff's full-sized avatar

brunoathaíde brun0xff

  • Software Engineer
  • Lisbon
View GitHub Profile
def typecasting(obj, new_type):
try:
if obj == '' or obj is None:
return None
return new_type(obj)
except (ValueError, TypeError):
return None

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@brun0xff
brun0xff / read-data-from-storage-to-bq.py
Last active July 8, 2018 00:28
read data from google storage bucket to google cloud datalab --python3.x and jupyter-notebook
# How to read data from Google storage cloud to Google cloud datalab
import google.datalab.storage as storage
import pandas as pd
from io import BytesIO
mybucket = storage.Bucket('BUCKET_NAME')
data_csv = mybucket.object('data.csv')
uri = data_csv.uri
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
path = 'datasets-amazon/1-dependency-parser/dep-cam.json'
with open(path) as dataset:
line = dataset.readline()
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc, char const *argv[])
{
double a, b, c, delta, raizdelta, r1, r2;
scanf("%lf", &a);
#include <iostream>
using namespace std;
typedef struct elem{
int pid;
int ing;
int nig;
int dur;
int esp;
from mako.template import Template
from mako.runtime import Context
tpl_xml = '''
<doc>
% for i in data:
<p>${i}</p>
% endfor
</doc>
'''
#!/usr/bin/python
# -*- coding: utf-8 -*-
from nltk.tag import StanfordPOSTagger
from nltk.tokenize import word_tokenize
model = '/<PATH>/stanford-postagger-full-2016-10-31/models/english-bidirectional-distsim.tagger'
jar = '/<PATH>/stanford-postagger-full-2016-10-31/stanford-postagger.jar'
#!/usr/bin/python
# -*- coding: utf-8 -*-
code = """
\""" this is a comment \"""
#comment one
\""" this is another fucking comment \"""
a = 4
b = 2
\""" now im gonna to test my code \"""
#include <iostream>
#include "aloca.h"
using namespace std;
/*
Anda na lista de livres e checa se o bloco à esquerda do ~ponteiro ta livre,
retorna ponteiro pro node na lista de livres caso esteja livre, e retorna
NULL caso contrario