Skip to content

Instantly share code, notes, and snippets.

View dstegelman's full-sized avatar

Derek Stegelman dstegelman

  • Colorado State University @csu-chhs
  • Northern Colorado, USA
View GitHub Profile
@nrollr
nrollr / MySQL_macOS_Sierra.md
Last active June 7, 2024 20:53
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@kracekumar
kracekumar / Writing better python code.md
Last active February 19, 2024 03:06
Talk I gave at June bangpypers meetup.

Writing better python code


Swapping variables

Bad code

import re
from django.conf import settings
from django.core import cache as django_cache
from mock import patch
from rest_framework.permissions import SAFE_METHODS
from rest_framework.response import Response
class CachedResourceMixin (object):
@property
@powellc
powellc / queryset-troubles-django-cbv.md
Last active December 16, 2015 15:09
In Django, class-based views are neat and all, but there be monsters out there too.

Queryset Troubles in Django Class-based Views

So in a recent project I had a very strange publishing bug where two models out of more than a dozen or so, were tossing out 404s where a detail page should be. We had just instituted a lot of caching pieces to the project, which turned out to be red-herrings and probably had something to do with how long it took to track down this bug. But for the sake of the internet and anyone else who finds their model's publish datetimes strangely cached despite their best efforts to get them to show up, here's some good advice:

Don't use the "queryset" model attribute for your view class, override the "get_queryset" function.

In code:

Where people struggle learning Django

Over the last 3 years or so I've helped a bunch of companies, small and large, switch to Django. As part of that, I've done a lot of teaching Django (and Python) to people new to the platform (and language). I'd estimate I've trained something around 200-250 people so far. These aren't people new to programming — indeed, almost all of them are were currently employed as software developers — but they were new to Python, or to Django, or to web development, or all three.

In doing so, I've observed some patterns about what works and what doesn't. Many (most) of the failings have been my own pedagogical failings, but as I've honed my coursework and my skill I'm seeing, time and again, certain ways that Django makes itself difficult to certain groups of users.

This document is my attempt at organizing some notes around what ways different groups struggle. It's not particularly actionable — I'm not making any arguments about what Django should or shouldn't do (at least

@ono
ono / travis-pro.markdown
Created November 1, 2012 14:38
Travis CI pro beta note

1st November, 2012

Summary

Luckily we have got a beta access to Travis CI pro which allows you to build your private repos on github. I did some research for my work and we have decided to replace our Jenkins to Travis CI pro. I leave some notes here.

Background

We have bunch of private repositories, mainly Ruby (rails and gems), on github that we want to continuously test. We currently maintain two CI servers: Buildbot for legacy project and Jenkins for recent projects. On this research, I simply ignored the legacy one and evaluated Travis CI pro as an alternative for Jenkins.

@dergachev
dergachev / README.md
Created October 10, 2012 16:49
Vagrant tutorial

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

@fcurella
fcurella / django_postgis_on_os_x.md
Created July 27, 2012 15:22
Django and Postgis on OS X

Django and Postgis on OS X

Install Homebrew

Install a few things with homebrew:

Notice that some packages give you information at the end, read it carefully. To recall that info use brew info like this: $ brew info postgresql

$ brew install python --universal
@dstegelman
dstegelman / cutomqueryset.py
Last active October 1, 2015 20:38
Chainable Custom Model Manager
from django.db.models.query import QuerySet
from django.db.models import Manager
from datetime import date
class EventQuerySet(QuerySet):
def published(self):
return self.filter(published=True)
def available_for_adding(self):