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 / 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):
@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
@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) ])
@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