Skip to content

Instantly share code, notes, and snippets.

View josefmonje's full-sized avatar

@josefmonje josefmonje

View GitHub Profile
@josefmonje
josefmonje / onename.io
Created April 18, 2014 08:46
onename.io
#verifymyonename +josefmonje
@josefmonje
josefmonje / admin.py
Last active March 1, 2016 08:38
Brute force registration of Django models to admin
from django.contrib import admin
from django.db.models import Model
from . import models
"""
Brute force registration of Django models to admin
exclude_models = models from 3rd party models, anything that gives errors :)
@josefmonje
josefmonje / The Technical Interview Cheat Sheet.md
Created February 14, 2016 14:54 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@josefmonje
josefmonje / requirements.txt
Created February 14, 2016 16:42
Django requirements.txt base
yolk # package status checker
ipython # better shell
django-debug-toolbar # runserver debug toolbar
django-environ # settings in environment
django-admin-tools # better django admin
django-extensions # management command extension
pygraphviz # django_extensions > graph_models
werkzeug # django_extensions > enhanced runserver
@josefmonje
josefmonje / form.html
Last active March 1, 2016 15:47
Bootstrap-compatible generic Django form
{% extends 'base.html' %}
{% load widget_tweaks %}
{% block content %}
<form class="form-horizontal" method="POST" enctype="multipart/form-data">{% csrf_token %}
<fieldset>
<legend>{{ title }}</legend>
{% for field in form.visible_fields %}
{% if field.errors %}
@josefmonje
josefmonje / betterpaginator.py
Created March 29, 2016 07:24 — forked from pylemon/betterpaginator.py
django: better paginator
from django.core.paginator import Paginator, EmptyPage
class BetterPaginator(Paginator):
"""An enhanced version of the Paginator"""
def __init__(self, getvars, *args, **kwargs):
"""default args are:
self, object_list, per_page, orphans=0, allow_empty_first_page=True
@josefmonje
josefmonje / forms.py
Created March 29, 2016 07:28
Django UserCreationForm - check if user exists
def clean_username(self):
username = self.cleaned_data["username"]
try:
User.objects.get(username=username)
except User.DoesNotExist:
return username
raise forms.ValidationError(_("A user with that username already exists."))
## Based on: https://github.com/calpolydatascience/jupyterhub-deploy-data301/blob/master/roles/nginx/templates/nginx.conf.j2
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@josefmonje
josefmonje / fullquery
Created June 8, 2016 09:23 — forked from OllieJones/fullquery
Fast nearest-location finder for SQL (MySQL, PostgreSQL, SQL Server)
SELECT zip, primary_city,
latitude, longitude, distance
FROM (
SELECT z.zip,
z.primary_city,
z.latitude, z.longitude,
p.radius,
p.distance_unit
* DEGREES(ACOS(COS(RADIANS(p.latpoint))
* COS(RADIANS(z.latitude))
apt-get update
# raspi-config
# http://archive.raspberrypi.org/debian/pool/main/r/raspi-config/#sthash.j0qHnuVP.dpuf
# http://archive.raspberrypi.org/debian/pool/main/r/raspi-config/raspi-config_20161207_all.deb
# dpkg -i raspi-config*.deb
# raspi-conifig --expand-rootfs
# Linux utilities
apt-get install curl \
wget \