Skip to content

Instantly share code, notes, and snippets.

View imakecodes's full-sized avatar
🔬
Researching...

Michel Wilhelm imakecodes

🔬
Researching...
View GitHub Profile
@imakecodes
imakecodes / README.md
Created May 24, 2018 12:49 — forked from denji/README.md
Simple Sentry docker-compose.yml
  1. Download docker-compose.yml to dir named sentry
  2. Change SENTRY_SECRET_KEY to random 32 char string
  3. Run docker-compose up -d
  4. Run docker-compose exec sentry sentry upgrade to setup database and create admin user
  5. (Optional) Run docker-compose exec sentry pip install sentry-slack if you want slack plugin, it can be done later
  6. Run docker-compose restart sentry
  7. Sentry is now running on public port 9000
@imakecodes
imakecodes / gist:d273b8835991ac310fa532854c6767fd
Created July 17, 2018 16:45 — forked from fnielsen/gist:1226214
Email classification example with Python, NLTK, ...
documents = [ dict(
email=open("conference/%d.txt" % n).read().strip(),
category='conference') for n in range(1,372) ]
documents.extend([ dict(
email=open("job/%d.txt" % n).read().strip(),
category='job') for n in range(1,275)])
documents.extend([ dict(
email=open("spam/%d.txt" % n).read().strip(),
category='spam') for n in range(1,799) ])
import requests
data = {
'pagina': '0',
'tipo_consulta': '0',
'nr_inscricao': '123123',
'cbxadv': '1',
'id_tipoinscricao': '1',
'nome_advogado': '',
@imakecodes
imakecodes / pre-commit
Last active February 25, 2021 11:42 — forked from jarodsmk/pre-commit
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit, detects merge markers, and prettifies your code!
#!/bin/sh
# ------------------------------------------------------------------------------------#
# Console log check
# ------------------------------------------------------------------------------------#
# Redirect output to stderr.
exec 1>&2
# Enable user input
exec < /dev/tty
# Updated regexp to only look at the addition of console.log's on the current branch HEAD

michelw Michel Wilhelm

Keybase proof

I hereby claim:

  • I am imakecodes on github.
  • I am michelw (https://keybase.io/michelw) on keybase.
  • I have a public key ASBx1LNf0SAQPCyH3HyOQkwQxe5VIlJ6p-VfJy-2JPjqXAo
@imakecodes
imakecodes / example.py
Created November 19, 2019 20:52
Este snippet foi obtido em https://alysivji.github.io/mocking-functions-inputs-args.html e mostra como mockar um recurso e de acordo com os parâmetros de entrada do recurso retornar diferentes valores
# test_calc_stats.py
import calc_stats
user_data = [
{ 'id': 1, 'name': 'Aly', 'email': 'alysivji@gmail.com'},
]
activity_data = [
{ 'id': 65, 'description': 'morning jog', 'distance': 3.1 },
from threading import Thread
class QueryFuture(Thread):
def __init__(self, q):
self.q = q
super().__init__()
def run(self):
self.docs = presto.execute_response(self.q)
import pendulum
import requests
import os
timestamp = pendulum.now().format("YYYY-MM-DD-HH-mm")
filename = f"{timestamp}.json"
filepath = f"/home/mwilhelm/notebook/will/data/{filename}"
latest = f"/home/mwilhelm/notebook/will/data/latest.json"
base_url = "https://balneabilidade.ima.sc.gov.br/relatorio/mapa"
for i in range(5):
@imakecodes
imakecodes / models.py
Created April 18, 2020 01:09 — forked from jacobian/models.py
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
from bisect import bisect
from random import random
def weighted_choice(choices):
if not choices:
return None
values, weights = zip(*choices)
total = 0