Skip to content

Instantly share code, notes, and snippets.

View bikemule's full-sized avatar

bikemule

  • Kraken Technologies
  • Brooklyn, NY
View GitHub Profile
@bikemule
bikemule / portfinder.sh
Created June 3, 2022 22:59
bash function to find a
# Find what port a program is using
function portfinder() {
# Find out what port a program is using.
# First and only argument is the process name
# used to grep output of ps command
# Usage: portfinder name_of_process
# Example output:
# node 87825 user 35u IPv4 0xaffd45cf13a62c85 0t0 TCP *:62883 (LISTEN)
@bikemule
bikemule / graph_models.sh
Last active March 21, 2020 14:41
Django model graph of specific apps, grouped by app, without inheritance
# Graph the models of specified apps.
# manage.py graph_models arguments:
# -g = Group models by app.
# -E = Do not show model inheritance.
# --output output_file, used with --pygraphviz
# `date --rfc-3339=date` = YYYY-MM-DD
python manage.py graph_models --pygraphviz -gE --output modelsgraph-`date --rfc-3339=date`.png appname1 appname2
/*
select * from crime_scene_report where type='murder' and city='SQL City';
date type description city
20180215 murder REDACTED REDACTED REDACTED SQL City
20180215 murder Someone killed the guard! He took an arrow to the knee! SQL City
20180115 murder Security footage shows that there were 2 witnesses. The first witness lives at the last house on "Northwestern Dr". The second witness, named Annabel, lives somewhere on "Franklin Ave". SQL City
select * from interview where person_id in (select id from person where address_street_name like '%Northwestern Dr%' or address_street_name like '%Franklin Ave%');
Perhaps a way to narrow it down more, but the last two rows say:
'''
Don't know why I wanted to document this in such detail, but here it is.
From: https://fivethirtyeight.com/features/how-fast-can-you-type-a-million-letters/
Some number, N, of people need to pee, and there is some number, M, of urinals
in a row in a men's room. The people always follow a rule for which urinal they
select: The first person goes to one on either far end of the row, and the rest
try to maximize the number of urinals between them and any other person. So the
second person will go on the other far end, the third person in the middle, and
# Trying to explain self in Python
class Number:
class_value = 1
def __init__(self, value):
# self is used here to refer to the newly created obj because __init__ is magic and it's a constructor
# All OO langs have to have constructors
self.value = value
@bikemule
bikemule / gist:4973606b6ffae233608d
Created March 9, 2015 18:56
pip install pgmagick error log
This file has been truncated, but you can view the full file.
Collecting django==1.6.6 (from -r requirements.txt (line 1))
Downloading Django-1.6.6-py2.py3-none-any.whl (6.7MB)
Collecting psycopg2==2.5 (from -r requirements.txt (line 2))
Downloading psycopg2-2.5.tar.gz (703kB)
Collecting pycurl==7.19.0 (from -r requirements.txt (line 3))
Downloading pycurl-7.19.0.tar.gz (70kB)
Using curl-config (libcurl 7.30.0)
Collecting dateutils==0.6.6 (from -r requirements.txt (line 4))
Downloading dateutils-0.6.6.tar.gz
@bikemule
bikemule / gist:3dce8a886c9b80f6801f
Created March 9, 2015 18:20
brew install pgmagick error OS X 10.9.4
/usr/local/include/boost/python/class.hpp:266:11: note: candidate function template not viable: requires 5 arguments, but 2 were provided
self& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3 const& a3)
^
1 error generated.
error: command 'clang' failed with exit status 1