Skip to content

Instantly share code, notes, and snippets.

View tclancy's full-sized avatar

Tom Clancy tclancy

View GitHub Profile
// these are breakpoints made with Neat grids.
$medium-screen: new-breakpoint(min-width 640px 12);
$bigger-screen: new-breakpoint(min-width 910px 12);
$hugest-screen: new-breakpoint(min-width 1200px 12);
// to use: put this div at the top of your page
// <div id="sizer"></div>
#sizer {
font-size: 0.5em;
from compressor.filters import CompilerFilter
class CoffeeCompilerFinder(staticfiles.finders.AppDirectoriesFinder):
"""
A quick hacked up staticfiles-finder that will automatically recompile .coffee files to .js and serve the .js file
It will respond to a request for /foo/bar/baz.js and if the coffee-file with the same name in that same dir is newer then
then js-file requested then the js-file will be recompiled.
I did this to not have to manually recompile my scripts or use the watcher and still be compatible with require.js
without have to change the code once i deploy with compiled js-files. it depends on django-compressor at the moment
but if you dont use that its just a small class to lift out from it.
class SomeView(View):
def dispatch(self, request, *args, **kwargs):
# imports and start profiling
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
# all logic runs here
@arnaud-lb
arnaud-lb / pre-commit.sh
Created December 1, 2012 11:58 — forked from yangsu/pre-commit.sh
pre-commit git hook for crushing images
#!/bin/sh
# to use, save this file as .git/hooks/pre-commit in your git repo
# make sure to add execute permissions using: chmod +x .git/hooks/pre-commit
command -v pngcrush >/dev/null 2>&1 || {
echo "\033[1mPlease install pngcrush to reduce images size before commit\033[0m"
echo "Install pngcrush with the following:"
echo "\t \033[1mbrew install pngcrush\033[0m"
echo "OR"
echo "\t Site: \033[1m\033[4mhttp://pmt.sourceforge.net/pngcrush/\033[0m"
echo "\t Download: \033[1m\033[4mhttp://sourceforge.net/projects/pmt/files/\033[0m"
@kaesetoast
kaesetoast / dynamic-gulp-dest
Last active March 10, 2017 20:58
write gulp output to dynamic destinations
return gulp.src('app/**/scss/++/*.scss')
.pipe(sass())
.pipe(gulp.dest(function(files) {
return path.join(file.base, '../css');
}));
@ckinsey
ckinsey / decorators.py
Created March 22, 2014 16:34
Require SSL for Django views via a decorator. You'll need some setup in your web server to support the request.is_secure() method--see the Django docs.
from functools import wraps
from django.conf import settings
from django.http import HttpResponseRedirect
def require_ssl(view):
"""
Decorator that requires an SSL connection. If the current connection is not SSL, we redirect to the SSL version of
the page.
@unbracketed
unbracketed / gist:228457
Created November 7, 2009 01:45
Django virtualenv postactivate hook
#I usually drop something like this into my virtualenv's postactivate for some
#quick and handy shortcuts to common Django commands.
#This way dropping in to do some work on any arbitrary project is as easy as:
# 1. workon <project name>
# 2. djr
cd /path/to/site/root
#Django command shortcuts
alias dj='python manage.py'
var org_str = "j8ck72di";
var session_str = "4734a9fc27f7fee1aa58f66046af6c49";
var base_str = "https://ct-m-fbx.fbsbx.com/fp";
var page_id = "1";
var ip_addr_str = "820139e7306525d7";
var tarpitting_param = "";
var carrier_id_enabled = "false";
var flash_tags = "true";
@mattmcc
mattmcc / models.py
Created March 27, 2013 00:24
Quick & dirty "read-only" model for using SQL views
class ViewManager(models.Manager):
def bulk_create(self, *args, **kwargs):
raise NotImplementedError
def create(self, *args, **kwargs):
raise NotImplementedError
def get_or_create(self, *args, **kwargs):
raise NotImplementedError
@jsmits
jsmits / flake8.xml
Last active August 2, 2018 16:52
PyCharm 3.x Flake8 Configuration XML
<toolSet name="Code Checking">
<tool name="Flake8" showInMainMenu="true" showInEditor="true" showInProject="true" showInSearchPopup="true" disabled="false" useConsole="true" showConsoleOnStdOut="false" showConsoleOnStdErr="false" synchronizeAfterRun="true">
<exec>
<option name="COMMAND" value="/usr/local/bin/flake8" />
<option name="PARAMETERS" value="--max-complexity 10 $FilePath$" />
<option name="WORKING_DIRECTORY" value="$ProjectFileDir$" />
</exec>
<filter>
<option name="NAME" value="Filter 1" />
<option name="DESCRIPTION" />