Skip to content

Instantly share code, notes, and snippets.

@rogerallen
rogerallen / us_state_abbrev.py
Last active June 18, 2024 01:27
A Python Dictionary to translate US States to Two letter codes
# United States of America Python Dictionary to translate States,
# Districts & Territories to Two-Letter codes and vice versa.
#
# Canonical URL: https://gist.github.com/rogerallen/1583593
#
# Dedicated to the public domain. To the extent possible under law,
# Roger Allen has waived all copyright and related or neighboring
# rights to this code. Data originally from Wikipedia at the url:
# https://en.wikipedia.org/wiki/ISO_3166-2:US
#
@wrunk
wrunk / httplib2_post_json.py
Created February 17, 2012 20:49
Python httplib2 POST json body with auth example
#! /usr/bin/env python
'''
This is more of a personal reference as I use json very often.
The httplib2 examples are VERY good, and you should refer to them:
http://code.google.com/p/httplib2/wiki/Examples
'''
from httplib2 import Http
try:
@robmiller
robmiller / .gitconfig
Created July 17, 2013 07:52
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
@miljan-aleksic
miljan-aleksic / calendar-matrix.js
Last active August 19, 2022 12:24
Calendar Matrix (date-fns, ES6) inspired by https://github.com/bclinkinbeard/calendar-matrix
import getYear from 'date-fns/get_year'
import getMonth from 'date-fns/get_month'
import addDays from 'date-fns/add_days'
import startOfWeek from 'date-fns/start_of_week'
const rows = range(6)
const cols = range(7)
/**
* Returns a two-dimensional array with calendar represented dates
@EmmanuelTsouris
EmmanuelTsouris / Install-VSCode.ps1
Last active May 18, 2024 17:25
Download and Silently Install Visual Studio Code (VSCode)
<#
.SYNOPSIS
This script installs Visual Studio Code Silently.
.DESCRIPTION
The script downloads the latest VSCode installer and performs a silent installation.
.NOTES
Run this script on a Windows Server instance.
#>
@benoitvogel
benoitvogel / wagtail_hooks.py
Created April 8, 2018 23:26
Add a button linked to a span with a class in Wagtail/Draftail
import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler
from wagtail.core import hooks
@hooks.register('register_rich_text_features')
def register_custom_style_feature(features):
feature_name = 'mycustomstyle' # .mycustomstyle will have to be defined in the CSS in order to get frontend styles working
type_ = feature_name.upper()
tag = 'span'
@robodl
robodl / colors.css
Last active April 10, 2024 17:41
Wagtail - Draftail - Multiple color highlighter
.cm-green {
background-image: linear-gradient(30deg,#16d6d9,#96cc29);
}
.cm-blue {
background-image: linear-gradient(30deg,#009cf3,#16d6d9);
}
.cm-pink {
background-image: linear-gradient(30deg,#ff2277,#7a288c);
@ckrybus
ckrybus / 1integrate-django-filter-django-tables2-django-crispy-forms.md
Last active May 13, 2024 05:01
How to integrate django-crispy-forms, django-tables2 and django-filter in order to display a paginated table with filter functionality.
@sdondley
sdondley / tmux split-window subcommand.md
Last active June 10, 2024 00:21
Super Guide to the split-window tmux Subcommand (and Beyond)

Super Guide to the split-window tmux Subcommand (and Beyond)

Guide overview

tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the

@MattFanto
MattFanto / README.md
Last active November 16, 2023 16:51
Django appenddata

Alternative command to django loaddata when it is necessary to append fixture objects into an existing database. Instead of merging fixture data with your existing models (as it does loaddata) it appends all fixtures object by resetting all pk. M2M relations are managed at the end of the process, mapping the old primary keys with the new primary keys:

Example of test (appending data from Website2 into Website1):

# Website 1
python manage.py dumpdata app1 app2 ... > test_append_data_fixtures_pre.json

# Website 1
python manage.py dumpdata app1 app2 ... &gt; fixture_to_import.json