Skip to content

Instantly share code, notes, and snippets.

phil plante pplante

Block or report user

Report or block pplante

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View auto-virtualenv.sh
# Automatically activate Git projects' virtual environments based on the
# directory name of the project. Virtual environment name can be overridden
# by placing a .venv file in the project root with a virtualenv name in it
function workon_cwd {
# Check that this is a Git repo
GIT_DIR=`git rev-parse --git-dir 2> /dev/null`
if [ $? == 0 ]; then
# Find the repo root and check for virtualenv name override
GIT_DIR=`\cd $GIT_DIR; pwd`
PROJECT_ROOT=`dirname "$GIT_DIR"`
View test.js
<a class="btn">My Button</a>
View tasty-fast-dehydrate.py
from tastypie import fields
from tastypie.bundle import Bundle
class FastDehydratableForeignKey(fields.ForeignKey):
def dehydrate(self, bundle):
if isinstance(bundle, Bundle):
other_resource = self.to_class()
if hasattr(other_resource, '_meta') and other_resource._meta.object_class:
fk_field = bundle.obj._meta.get_field(self.attribute)
@pplante
pplante / post-receive.sh
Created Oct 22, 2012 — forked from stas/post-receive.sh
Heroku like deployment git hooks
View post-receive.sh
#!/bin/bash
# (Re)spawn the application
function spawn () {
local ps_name=$1
local spawn_cmd=$2
local pids=`ps -C $ps_name -o pid=`
if [ ${#pids} -ne 0 ]
then
echo "Sending TERM to $pids..."
@pplante
pplante / robolectric-library-resource-loading.java
Created Aug 28, 2012
Robolectric does not support loading resources from an Android Library project such as ActionBarSherlock of FlyInMenu, so this patch allows you to specify a library project to load resources in tests.
View robolectric-library-resource-loading.java
// In ResourceLoader.java I added the following method:
//
public void loadLibraryProjectResources(File libraryProjectRoot) throws Exception {
File systemResourceDir = getSystemResourceDir(getPathToAndroidResources());
File localValueResourceDir = getValueResourceDir(libraryProjectRoot);
File systemValueResourceDir = getValueResourceDir(systemResourceDir);
loadStringResources(localValueResourceDir, systemValueResourceDir);
loadPluralsResources(localValueResourceDir, systemValueResourceDir);
loadValueResources(localValueResourceDir, systemValueResourceDir);
@pplante
pplante / areyoufuckingkiddingme.java
Created Jun 27, 2012
fixes a stupid bug with lwjgl on osx when the user presses cmd+q in fullscreen the app hangs causing you to restart OSX.
View areyoufuckingkiddingme.java
// see: http://www.java-gaming.org/index.php?topic=23640.0
Application.getApplication().setQuitHandler(new QuitHandler() {
@Override
public void handleQuitRequestWith(AppEvent.QuitEvent quitEvent, QuitResponse quitResponse) {
Gdx.app.exit();
}
});
@pplante
pplante / MemoryTrackingAssetManager.java
Created May 12, 2012
This is a custom wrapper around the AssetManager in LibGDX providing the ability to track how much texture memory is allocated.
View MemoryTrackingAssetManager.java
/*
Copyright (c) 2012. HappyDroids LLC <contact@happydroids.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTIO
View GameObjectAccessor.java
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenAccessor;
import com.unhappyrobot.entities.GameObject;
public class GameObjectAccessor implements TweenAccessor<GameObject> {
static {
Tween.registerAccessor(GameObject.class, new GameObjectAccessor());
}
public static final int POSITION = 1;
@pplante
pplante / python-expectations-selenium.py
Created Oct 4, 2011
I wasn't happy with the existing selenium integrations for django, so I wrote one that is compatible with my python-expectations library. Here is a sample test that logs into admin, then checks for my username in the header.
View python-expectations-selenium.py
class ApplicationViewTests(SeleniumTestCase):
def test_django_test_server_is_running(self):
self.login()
with self.navigate_to('/admin') as page:
expect(page).to_have_selector('#user-tools')
expect(page.find('#user-tools')).to_contain_text('Welcome, pplante.')
def login(self, username=None, password=None):
@pplante
pplante / jquery.ajaxq.js
Created Jul 26, 2011
jQuery AjaxQ(ueue)
View jquery.ajaxq.js
// Copyright (C) 2011 Philip Plante <@pplante>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
You can’t perform that action at this time.