Skip to content

Instantly share code, notes, and snippets.

View mpasternacki's full-sized avatar

Maciej Pasternacki mpasternacki

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mpasternacki on github.
  • I am mpasternacki (https://keybase.io/mpasternacki) on keybase.
  • I have a public key whose fingerprint is 5810 5238 081B 0C33 46BF A0F5 A43B 1DDA E9A0 8CCF

To claim this, I am signing this object:

@mpasternacki
mpasternacki / smart_ipython
Created September 8, 2009 10:19
Smart IPython script for comfortably running Django's manage.py shell with ipython.el
#!/bin/sh
set -e
/bin/echo -n "Select Django project/dir, or press enter for plain ipython: "
read selection
case $selection in
'') exec ipython ;;
sj) cd /Users/japhy/Projekty/SetJam/setjam/setjam ;;
*) cd $selection ;;
@mpasternacki
mpasternacki / duplicity-runner.sh
Created September 23, 2009 19:19
Script for easy Duplicity backup, suitable for both /etc/cron.daily/ and running by hand.
#!/bin/sh
set -e
local=/
remote=s3+http://***/
# figure out correct positional arg order for duplicity
case $1 in
''|full|incremental) positional="$local $remote" ;;
restore|verify) positional="$remote $local" ;;
*) positional="$remote" ;;
diff -u /usr/lib/ruby/user-gems/1.8/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy.rb /var/folders/ES/ESqLaiVrElWZyCirD8h3nk\+\+\+TI/-Tmp-/buffer-content-411Nzk
--- /var/folders/ES/ESqLaiVrElWZyCirD8h3nk+++TI/-Tmp-/buffer-content-411Nzk 2009-10-19 12:23:17.000000000 +0200
+++ /usr/lib/ruby/user-gems/1.8/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy.rb 2009-10-19 11:41:04.000000000 +0200
@@ -51,7 +51,7 @@
_cset(:release_path) { File.join(releases_path, release_name) }
_cset(:releases) { capture("ls -xt #{releases_path}").split.reverse }
-_cset(:current_release) { File.join(releases_path, releases.last) }
+_cset(:current_release) { File.join(releases_path, releases.last || "*LATEST_RELEASE*") }
_cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil }
@mpasternacki
mpasternacki / django-paypal-dateutil.diff
Created November 11, 2009 18:21
Monkey-patch django-paypal for issue #17
diff --git a/standard/forms.py b/standard/forms.py
index 6639146..f13aae4 100644
--- a/standard/forms.py
+++ b/standard/forms.py
@@ -199,12 +199,52 @@ class PayPalSharedSecretEncryptedPaymentsForm(PayPalEncryptedPaymentsForm):
else:
self.fields['notify_url'].initial += secret_param
+try:
+ import dateutil.parser
@mpasternacki
mpasternacki / README.md
Created November 23, 2009 12:43
Local ASDF-Install Sandbox

Local ASDF-Install Sandbox

I needed an installation of ADSF-Install that wouldn’t interfere with system-wide, user-wide or even project-wide settings but that would allow me to fetch, e.g., Tinaa and document my project. So, I want to create ASDF-install sandbox that would be completely self-contained. And I did. Here’s how:

First, download ASDF-Install using darcs:

darcs get http://common-lisp.net/project/asdf-install/darcs/asdf-install

Downloaded ASDF-install directory will be our sandox (yes, the self-contained sandbox is this self-contained it uses own local copy of ASDF-Install itself). Now, let’s create place for downloaded systems in sandbox and, to avoid overpopulating ASDF:*CENTRAL-REGISTRY*, symlink asdf-install itself there:

@mpasternacki
mpasternacki / cl-md5-salted-passwords.lisp
Created November 23, 2009 12:16
Salted password hashes with CL-MD5.
;;; This program is free software. It comes without any warranty, to
;;; the extent permitted by applicable law. You can redistribute it
;;; and/or modify it under the terms of the Do What The Fuck You Want
;;; To Public License, Version 2, as published by Sam Hocevar. See
;;; http://sam.zoy.org/wtfpl/COPYING for more details.
(defparameter +hash-salt-chars+ "qwertyuiopasdfghjklzxcvbnm")
(defparameter +salt-length+ 5)
(defun md5str (password)
"Return string form of PASSWORD's MD5sum."
@mpasternacki
mpasternacki / tail-n-mail.rb
Created January 8, 2010 21:45
Periodically send new lines in log file to specified email address.
# Script to periodically send new lines in log file to specified mail address.
#
# Similar to http://bucardo.org/wiki/Tail_n_mail - but I needed
# substitution to handle newlines in Python-generated messages, and it
# was faster to homebrew my own script than to add features to an
# already overfeatured Perl script. And I want to practice Ruby - seems
# to be fine for small, one-off scripts.
#
# License: WTFPL or MIT, whichever you prefer.
@mpasternacki
mpasternacki / htmlize-fragments.el
Created January 24, 2010 17:49
Replace fragment of current buffer with htmlized file.
(require 'htmlize)
(defun jph/strip-htmlized-buffer ()
"Strip htmlized buffer to <pre> tag, copying style attribute from <body> to <pre>."
(interactive)
(goto-char (point-min))
(re-search-forward "<body\\( style=[^>]*\\)>")
(let ((style (match-string 1)))
(search-forward "<pre")
(insert style)
@mpasternacki
mpasternacki / git-diffstat.sh
Created November 23, 2010 13:53
Full-width diffstat "porcelain" for git
#!/bin/bash
COLUMNS=`stty size | cut -d' ' -f2`
exec git diff --stat=$COLUMNS,$(($COLUMNS - 20)) "${@}"