Skip to content

Instantly share code, notes, and snippets.

# Requires https://github.com/andybak/codebase-python-api-client.git
import csv
from codebase.client import CodeBaseAPI
codebase = CodeBaseAPI(username='account name/user name', apikey='your key here', project='project name')
tickets = [codebase.ticket(ticket_id=x) for x in range(1,151)]
f = open('tickets.csv', 'wb')
tickets = [x['ticket'] for x in tickets if x.get('ticket')]
@acdha
acdha / django-1.2.5-lookup_allowed-example.py
Created December 23, 2010 20:29
How to whitelist other admin lookups with Django 1.2.5
class FooAdmin(ModelAdmin):
def lookup_allowed(self, key, value):
# NOTE: Django 1.2.5 changed the call signature to add the value
# Django 1.2.4 restricted the list of allowed lookups to only those
# specified in list_filter or date_hierarchy, which doesn't help when
# we need to filter on a list with thousands of options. We'll
# override that to allow the few which we actually use:
if key in ('related__pk', 'related__custom_field'):
return True
#!/usr/bin/python
from sorl.thumbnail.conf import settings
from sorl.thumbnail.base import ThumbnailBackend
FORMAT_DICT = {
'png': 'PNG',
'jpeg': 'JPEG',
'jpg': 'JPEG',
@Acorn-zz
Acorn-zz / gist:1059155
Created July 1, 2011 18:45
Load jQuery and jQuery UI in bookmarklet
((window, document, requirements, callback) ->
getScript = (url, callback) ->
script = document.createElement('script')
script.src = url
head = document.documentElement.childNodes[0]
done = false
script.onload = script.onreadystatechange = ->
if not done and (not (readyState = @readyState) or readyState == 'loaded' or readyState == 'complete')
done = true
callback()
@mtigas
mtigas / gist:2220161
Created March 27, 2012 20:55
Serving retina <img> tags in Django at the Spokesman-Review
<!--
Where {% jsmin %}{% endjsmin %} is a django template tag that
uses a Python port of Crockford's JSMin:
* http://www.crockford.com/javascript/jsmin.html
* https://gist.github.com/1b085c39b85347255557
Where {% mogrify %} is a custom template tag that generates a
URL with a resize command in the filename (semi-compatible with
ImageMagick mogrify) that is caught by a 404-handling script
running on the media server. A special hashed key is generated
@yagero
yagero / ScriptableObjectSingleton.cs
Last active November 14, 2017 13:54
Unity: Make your unique data accessible globally w/o having to link it, by using a 'ScriptableObjectSingleton'
using UnityEngine;
public class ScriptableObjectSingleton<T> : ScriptableObject where T : ScriptableObject
{
static T m_Instance = null;
public static T Instance
{
get
{
if (m_Instance == null)
@coordt
coordt / check_for_updates.py
Created April 8, 2011 18:39
Check locally installed packages against one or more package indexes for updates and list them.
#!/usr/bin/env python
"""
Use pip to get a list of local packages to check against one or more package
indexes for updated versions.
"""
import pip
import sys, xmlrpclib
from cStringIO import StringIO
from distutils.version import StrictVersion, LooseVersion
"Sampler2D" : {
"prefix": "sampl",
"body": [
"$1(\"$2\", 2D) = \"white\" {}",
"sampler2D $1;"
],
"description": "Makes a sampler2D property"
},
"Float" : {
// <copyright file="UpdateShaderGraphAssemblyInfo.cs" company="BovineLabs">
// Copyright (c) BovineLabs. All rights reserved.
// </copyright>
namespace BovineLabs.Vision.Editor.ShaderGraph
{
using System;
using System.IO;
using System.Linq;
using UnityEditor;
@almost
almost / async-await-lightning-talk.md
Last active September 12, 2019 09:07
Reactive 2015 Lightning Talk Proposal: Pyramids be gone!: ES7 Async Function

This is a proposal for a lightning talk at the Reactive 2015 conference.

NOTE: If you like this, star ⭐ the Gist - the amount of stars decides whether it makes the cut! You could also Retweet if you want :)

Pyramids be gone!

ES7 Async Functions

JavaScript is getting async functions (or already has them if you count Babel.JS) and with them a way to finally slay the evil pyramid. This new language feature lets you write asynchronous code that almost looks synchronous, while maintaining the same semantics as promises. This lets you shed your .then and .catch boilerplate and escape those nested callbacks in favour of clean, explicit, maintainable code.