Skip to content

Instantly share code, notes, and snippets.

View jphalip's full-sized avatar

Julien Phalip jphalip

View GitHub Profile
@jphalip
jphalip / TaskPaper-BetterStartAndDueDates.scpt
Created October 27, 2010 10:53
AppleScript to manage dates in TaskPaper. Contains improvements made on top of http://www.hogbaysoftware.com/wiki/StartAndDueDates - Works well with http://gist.github.com/648841
property dueTag : "due"
property startTag : "start"
property repeatTag : "repeat"
property todayTag : "today"
property tomorrowTag : "tomorrow"
property pastDueTag : "overdue"
property upcomingTag : "upcoming"
property doneTag : "done"
property inProgressTag : "inprogress"
property errorTag : "error"
@jphalip
jphalip / TaskPaper-BetterDecrementDateValue.scpt
Created October 27, 2010 11:04
AppleScripts to increment/decrement date values in TaskPaper. Contains improvements made on top of http://www.hogbaysoftware.com/wiki/IncrementDateValue and http://www.hogbaysoftware.com/wiki/DecrementDateValue - Works well with http://gist.github.com/648
on getTextFromDate(vDate)
set dText to ((year of vDate) as text) & "-"
set dayText to (month of vDate as number) as text
if length of dayText is 1 then
set dayText to "0" & dayText
end if
set dText to dText & dayText & "-"
set dayText to (day of vDate as number) as text
if length of dayText is 1 then
set dayText to "0" & dayText
@jphalip
jphalip / djpatch.py
Created August 25, 2011 11:25 — forked from jezdez/djpatch.py
A helper script to apply patches from Django's trac
#!/usr/bin/env python
"""
Obviously this is only useful if you have to deal with Django's
Trac a lot.
Mostly stolen from Jacob Kaplan-Moss, but improved by Jannis Leidel.
Reads a config file at ~/.djpatchrc, e.g.:
@jphalip
jphalip / gist:1341169
Created November 5, 2011 06:01
What could soon become the first Django admin Selenium test...
class SeleniumTests(SeleniumTestCase):
fixtures = ['admin-views-users.xml']
urls = "regressiontests.admin_views.urls"
def admin_login(self, username, password):
"""
Helper function to log into the admin.
"""
self.selenium.open('/test_admin/admin/')
self.selenium.type('username', username)
@jphalip
jphalip / gist:1341392
Created November 5, 2011 10:58
More Selenium tests for the Django admin
class AdminInlinesSeleniumTests(SeleniumTestCase):
fixtures = ['admin-views-users.xml']
urls = "regressiontests.admin_inlines.urls"
def admin_login(self, username, password):
"""
Helper function to log into the admin.
"""
self.selenium.open('/admin/')
self.selenium.type('username', username)
@jphalip
jphalip / gist:2849931
Created June 1, 2012 07:31
Some issues I'm having installing a bundle on
------------------------------------------------------------------------
zip-test.py:
import zipfile
zf = zipfile.ZipFile('django-compressor-1.1.2.pybundle', 'r')
zf.debug=3
------------------------------------------------------------------------
$ python zip-test.py
@jphalip
jphalip / gist:2865381
Created June 3, 2012 23:16
Patch for Django ticket #18379
diff --git a/django/views/debug.py b/django/views/debug.py
index 7bdf0d2..d95cd62 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -155,9 +155,20 @@ class SafeExceptionReporterFilter(ExceptionReporterFilter):
Replaces the values of variables marked as sensitive with
stars (*********).
"""
- func_name = tb_frame.f_code.co_name
- func = tb_frame.f_globals.get(func_name)
@jphalip
jphalip / gist:4614527
Last active December 11, 2015 14:29
Bash script for a Chef recipe to install PIL with Zlib and Freetype support in a Vagrant Ubuntu 32bit box. I wish PIL offered a cleaner way of doing this other than having to modify its setup.py.
%w{libjpeg-dev libfreetype6-dev}.each do |pkg|
package pkg do
action :install
end
end
bash "Install PIL from source" do
user vagrant
group vagrant
code <<-EOH
@jphalip
jphalip / goto.sh
Created July 10, 2013 16:10
Bash & zshell script for quickly accessing Python packages installed in the current virtualenv. Allows for tab completion. Associated blog post: http://julienphalip.com/post/55092823910/a-script-to-quickly-access-the-source-of-installed
# Author: Julien Phalip
# License: BSD
# Description: Change the current directory to the path of the given Python package.
function goto {
cd `python -c "import pkgutil; print(pkgutil.get_loader('$1').filename)"`
}
function _top_level_packages {
python -c "import pkgutil; print('\n'.join([name for loader, name, ispkg in sorted(pkgutil.iter_modules()) if ispkg]))"
@jphalip
jphalip / poweroff.py
Last active October 18, 2021 21:54
A Python script I wrote to quickly shut down Vagrant/VirtualBox VMs. See also the associated blog post: https://www.julienphalip.com/blog/fast-shutdown-of-development-vagrantvirtualbox/
#!/usr/bin/env python
import argparse
import re
import os
import subprocess
try:
import json
except ImportError:
import simplejson as json