Skip to content

Instantly share code, notes, and snippets.

View epicserve's full-sized avatar

Brent O'Connor epicserve

View GitHub Profile
/**
* MEDIA QUERY VARIABLES
* ------------------------------------------------------------------------- */
$tablet_landscape_width: "1024px";
$tablet_portrait_width: "768px";
$phone_landscape_width: "667px";
$phone_portrait_width: "375px";
/**
Mixin for Media Queries
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- (Or export to .app to run from spotlight.)
-- 2. Set domainName, vpnGroup and securePassword to their correct values for your VPN server and password
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility
-- 4. Enable Applescript Editor and System UI Server (or for this .app if so exported)
-- 5. Trigger script from the menu (or run from spotlight)
-- 6. Enjoy being connected
-- 7. Run script again to close connection
@epicserve
epicserve / mixins.py
Last active August 29, 2015 14:06
A handy little mixin for adding related objects to a view like DeleteView.
from django.views.generic.base import ContextMixin
from django.contrib.admin.utils import NestedObjects
class RelatedObjectsMixin(ContextMixin):
"""Adds the related_objects list to a views context """
def get_context_data(self, **kwargs):
context = super(RelatedObjectsMixin, self).get_context_data(**kwargs)
collector = NestedObjects(using='default')
@epicserve
epicserve / html_tags.py
Created September 17, 2014 19:04
Example of using bleach to strip out bad/evil code.
from django import template
from django.utils.safestring import mark_safe
import bleach
register = template.Library()
@register.filter
def strip_tags(text, valid_tags=['p', 'a', 'strong', 'em', 'ol', 'ul', 'li']):
if not isinstance(valid_tags, list):
{% if is_paginated %}
{% load i18n %}
<ul class="pagination">
<li{% if not page_obj.has_previous %} class="disabled"{% endif %}><a href="{% if not page_obj.has_previous %}#{% else %}?page={{ page_obj.previous_page_number }}{{ getvars }}{% endif %}">&laquo;</a></li>
{% if show_first %}
<li><a href="?page=1{{ getvars }}">1</a></li>
<li><span>...</span></li>
{% endif %}
var date1 = new Date();
var date2 = new Date(2099, 10, 11);
console.log(date1);
console.log(date2);
console.log(date1 >= date2);
console.log(date1 <= date2);
console.log(date1 == date2);
console.log(date1 === date2);
var date1 = new Date(2013, 10, 12);
var date2 = new Date(2013, 10, 12);
/*
When running the javascript in this file you get the following output ...
$ node js_date_test.js
Tue Nov 12 2013 00:00:00 GMT-0800 (PST)
Tue Nov 12 2013 00:00:00 GMT-0800 (PST)
false
console.log(new Date("Nov 11, 2013"));
console.log(new Date(2013, 11, 11));
// $ node js-date-test.js
// Mon Nov 11 2013 00:00:00 GMT-0800 (PST)
// Wed Dec 11 2013 00:00:00 GMT-0800 (PST)
@epicserve
epicserve / db-stacktrace.html
Last active March 23, 2021 11:23
A python context manager and decorator for debugging and optimizing queries for Django management commands.
<!DOCTYPE html>
<html>
<head>
<title>DB Stacktrace</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="http://getbootstrap.com/docs-assets/css/pygments-manni.css" rel="stylesheet" media="screen">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->