Skip to content

Instantly share code, notes, and snippets.

@eculver
eculver / wd-grid-view-overrides.js
Last active Aug 29, 2015
Script to override Wiredrive Wordpress plugin's grid-view with larger images.
View wd-grid-view-overrides.js
// create timeout to make sure it runs last
setTimeout(function () {
$(".wd-thumbnail").css('background-image', 'none').css({'width': 238, 'height': 144});
$(".wd-thumbnail img").css({'width': 238, 'height': 144}).show();
}, 200);
@eculver
eculver / randhash
Last active Aug 29, 2015
One-liner to get a random character string for use in fixtures or mocking.
View randhash
alias randhash='python -c "import md5; from datetime import datetime; print md5.new(datetime.now().strftime(\"%s\")).hexdigest()"'
View gist:8791514
/**
* Example Module in RequireJS
define([
'common/js/models/user',
'common/js/models/event',
'myapp/js/player'
], function () {
Ember.Application.initializer(ret = {
View sample_asset.json
{
"thumb": {
"href": "http://cache.mycdn.com/path/to/asset/a0324d3.jpg",
"width": 80,
"height": 80,
},
"asset": {
"id": 342393,
"title": "Client Commercial",
"filename": "mycommercial.m4v",
@eculver
eculver / replace_apt_sources.sh
Created Dec 26, 2013
Replace default Ubuntu apt repository URLs w/ DigitalOcean's
View replace_apt_sources.sh
sudo sed -i "s/archive\.ubuntu/mirrors.digitalocean/g" /etc/apt/sources.list
@eculver
eculver / invalidte_thumb.py
Last active Dec 29, 2015
Example of deleting a cached KVStore instance that sorl.thumbnail thumbnail templatetag creates. Pretty edge, but handy when thumbnails aren't being generated for whatever reason.
View invalidte_thumb.py
from sorl.thumbnail import default
from myapp.models import MyModel
# Get an model instance that has a File/ImageField associated with it. In this
# case the `thumb` attribute is an ImageField that we'd like to generate thumbnails for.
m = MyModel.objects.get(pk=10)
# Note the options passed to this method -- they are applied to the cache key so
# the ImageFile instance that is returned will be different for a different set
# of options kwargs provided here. In this case, the only option is `upscale=False`.
@eculver
eculver / test.py
Last active Dec 28, 2015
TestSettingsManager
View test.py
# This should be in a global namespace shared across your entire project
from django.conf import settings
NO_SETTING = ('!', None)
class TestSettingsManager(object):
"""
A class which can modify some Django settings temporarily for a
test and then revert them to their original values later.
View postgres-perms.sh
# create user
CREATE USER myuser WITH PASSWORD 'mypassword';
# create database
CREATE DATABASE mydatabase;
# grant access to user
GRANT ALL PRIVILEGES ON DATABASE mydatabase TO myuser;
# grant just create
View virtenv
#!/bin/bash
#
# This is a simple wrapper for generating commands for executables within a
# python virtualenv.
#
# Usage: virtenv env-name command [arg, arg, ...]
#
# env-name The name of the virtualenv for the command to be run in.
# command The command within the virtualenv's path to be run. The base path is usually $VIRTUALENV_HOME/$VIRTUALENV/bin.
# arg Any remaining arguments are passed to the command itself.
@eculver
eculver / app-config.js
Created Nov 4, 2013
This is an example of how we have set up our Ember.js application to use Require modules. The files below should be represented in this directory structure: https://dl.dropboxusercontent.com/u/1049965/require_example.png
View app-config.js
// We generate this file with Grunt based on system/environment level configuration that is contained elsewhere... YAML file, build number, etc.
(function (exports) {
exports.config = {
"appVersion": "dev",
"cdnUrl": "http://cdn.example.com"
}
// this last bit allows the config to be used both in the browser and in Node (Grunt)
}(typeof exports === 'undefined' ? this['WD'] = {}: exports));