Skip to content

Instantly share code, notes, and snippets.

View rh0dium's full-sized avatar

Steven rh0dium

View GitHub Profile
@philngo
philngo / climate_zones.csv
Last active March 5, 2024 17:41
IECC and Building America climate zones by United States county
State State FIPS County FIPS IECC Climate Zone IECC Moisture Regime BA Climate Zone County Name
AK 02 013 7 N/A Very Cold Aleutians East
AK 02 016 7 N/A Very Cold Aleutians West
AK 02 020 7 N/A Very Cold Anchorage
AK 02 050 8 N/A Subarctic Bethel
AK 02 060 7 N/A Very Cold Bristol Bay
AK 02 068 7 N/A Very Cold Denali
AK 02 070 8 N/A Subarctic Dillingham
AK 02 090 8 N/A Subarctic Fairbanks North Star
AK 02 100 7 N/A Very Cold Haines
@nick-merrill
nick-merrill / merge_model_objects.py
Created December 5, 2014 01:07
A variation on a snippet that handles one-to-one relationships by recursively migrating those relationships' field data to the `primary_object`'s related object.
# Based on https://djangosnippets.org/snippets/2283/
from django.db import transaction
from django.db.models import get_models, Model
from django.contrib.contenttypes.generic import GenericForeignKey
@transaction.atomic
def merge_model_objects(primary_object, alias_objects=None, keep_old=False):
"""
Use this function to merge model objects (i.e. Users, Organizations, Polls,
@NotSqrt
NotSqrt / settings_test_snippet.py
Last active May 1, 2022 01:34 — forked from nealtodd/settings_test_snippet.py
Another shot at this problem ..
class DisableMigrations(object):
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
MIGRATION_MODULES = DisableMigrations()
@matthewmueller
matthewmueller / osx-for-hackers.sh
Last active April 21, 2024 03:30
OSX for Hackers (Mavericks/Yosemite)
# OSX for Hackers (Mavericks/Yosemite)
#
# Source: https://gist.github.com/brandonb927/3195465
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Ask for the administrator password upfront
@mislav
mislav / aprompt.png
Last active February 11, 2024 06:40
My zsh prompt. No oh-my-zsh needed
aprompt.png
@ghickman
ghickman / add_inline.js
Created June 11, 2011 11:19
Add an inline Django form to the formset without reloading the page.
function add_inline_form(prefix) {
var count = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val(), 10);
var last_form = $('.' + prefix + ':last');
var new_form = last_form.clone(false).html(last_form.html().replace(
new RegExp(prefix + '-\\\\d-', 'g'), prefix + '-' + count + '-'));
new_form.find('input[type="text"], textarea').each(function () {
$(this).val('');
});
new_form.hide().insertAfter(last_form).slideDown(300);
from threading import Timer
class SuicidalKey(object):
"""
>>> k = SuicidalKey("asdf",30)
>>> k.key
'asdf'
>>> # Before 30 seconds are up
>>> k.reset_expiration(30)
>>> # Wait 30 seconds