Skip to content

Instantly share code, notes, and snippets.

Michael Bylstra mbylstra

Block or report user

Report or block mbylstra

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View elm-typescript-types-comparison.md
View elm-typescript-types-comparison.md
@mbylstra
mbylstra / scratchpad.py
Last active Mar 5, 2019
Django scratchpad file. A standalone Django script with the django environment loaded.Place in the root of your Django project. Assumes your settings.py is in a folder named 'main'.
View scratchpad.py
import os
import sys
project_dir = os.path.realpath(__file__)
sys.path.append(project_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = 'main.settings'
import django
from django.conf import settings
django.setup()
@mbylstra
mbylstra / gist:7727307
Created Dec 1, 2013
kill those wayward uwsgi processes that don't want to die with just killall
View gist:7727307
killall -SIGKILL uwsgi
@mbylstra
mbylstra / gist:aae6eac98d162a5cc9c2
Last active Sep 20, 2016
python mixin inheritance
View gist:aae6eac98d162a5cc9c2
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# MixinParent
# |
# Mixin A
# └--┐ |
# B
@mbylstra
mbylstra / gist:8050451
Created Dec 20, 2013
get a progress bar for large mysql imports and dumps
View gist:8050451
pv sqlfile.sql | mysql dbname
View print Exception stack trace
import traceback
try:
#some code
except Exception, e:
print ''.join(traceback.format_exception(*sys.exc_info()))
View mysql command line stuff
mysql> pager less; # use less for paging
mysql> SELECT * FROM something \G #one field per line (good for wide tables)
@mbylstra
mbylstra / create_utf8_mysql_db
Last active Dec 23, 2015
create a utf8 mysql database
View create_utf8_mysql_db
CREATE DATABASE some_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
@mbylstra
mbylstra / disable_mysql_foreign_key_checks
Created Sep 18, 2013
temporarily disable mysql foreign key checks, so you can do something dodgy:
View disable_mysql_foreign_key_checks
SET foreign_key_checks = 0;
DELETE FROM users where id > 45;
SET foreign_key_checks = 1;
You can’t perform that action at this time.