Skip to content

Instantly share code, notes, and snippets.

View tclancy's full-sized avatar

Tom Clancy tclancy

View GitHub Profile
@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
@vshjxyz
vshjxyz / Tastypie datatables with pagination.coffee
Last active February 28, 2019 06:23
This is a simple example of a working datatable using tastypie. I also Implemented the fnServerData so the datatable can paginate, search (via a query parameter configured in tastypie in the apply_filter method of the OrderResource), and sort columns using custom logics via the order_by parameter of tastypie.
@orders_table = $('#orders-table', element).dataTable
bProcessing: true
bServerSide: true
sAjaxSource: ORDERFULL_API
sAjaxDataProp: "objects"
aoColumns: [
# Put the resource name that corresponds to each table column
{
"mData": "id"
"sClass": "order-id"
@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"
@Nurdok
Nurdok / python_conversion.md
Last active December 16, 2022 03:45
Python Conversion

Python Number Conversion Chart

From To Expression
@elmarcoh
elmarcoh / table_init.js
Created October 26, 2012 21:35
Using Tastypie as an Ajax Source for DataTables
$('#participantes-table').dataTable({
bProcessing: true,
bServerSIde: true,
sAjaxSource: "/path/to/your/tastypie/api/list/objects/?format=json",
sAjaxDataProp: "objects",
aoColumns: [
// Put the resource name that corresponds to each table column
{'mData': "your"},
{'mData': "columns"},
],
@tony-landis
tony-landis / recurse_image_optimize.sh
Created October 18, 2012 01:36
Recursively Optimize JPGs and PNGs using PNGCRUSH and JPEGTRAN
#!/bin/sh
# script for optimizing images in a directory (recursive)
# pngcrush & jpegtran settings from:
# http://developer.yahoo.com/performance/rules.html#opt_images
# pngcrush
for png in `find . | grep .png`; do
echo "crushing $png ..."
pngcrush -rem alla -reduce -brute "$png" temp.png
@imkevinxu
imkevinxu / template.html
Created August 16, 2012 02:11
Django code to read uploaded CSV file
<form action="{% url %}" method="post" enctype="multipart/form-data">{% csrf_token %}
<input type="file" name="csv_file" />
<input type="submit" value="Upload" />
</form>
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.
@datagrok
datagrok / gist:2199506
Last active April 8, 2023 17:36
Virtualenv's `bin/activate` is Doing It Wrong
@ocean90
ocean90 / box-shadow.html
Last active April 11, 2024 13:54
CSS3 Box Shadow, only top/right/bottom/left and all
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;