Skip to content

Instantly share code, notes, and snippets.

@pckujawa
pckujawa / gist:2919894
Created June 12, 2012 20:19
Quick backup of environment variables (including PATH) in windows
cmd /k "date /t >> envvars.txt && time /t >> envvars.txt && set >> envvars.txt"
@pckujawa
pckujawa / gist:2870718
Created June 4, 2012 20:35
Hotkey controls for various music services (Pandora, Napster, Spotify, etc)
;
;#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;
; ############## Pandora ##############
; Ctrl+Forward -> next song
; Play/Pause -> play/pause
;
@pckujawa
pckujawa / gist:2789170
Created May 25, 2012 16:53
msbuild target for printing reserved properties
<Project DefaultTargets="PrintReservedProperties" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="PrintReservedProperties">
<Message Text="MSBuildProjectDirectory $(MSBuildProjectDirectory)" />
<Message Text="MSBuildProjectFile $(MSBuildProjectFile)" />
<Message Text="MSBuildProjectExtension $(MSBuildProjectExtension)" />
<Message Text="MSBuildProjectFullPath $(MSBuildProjectFullPath)" />
<Message Text="MSBuildProjectName $(MSBuildProjectName)" />
<Message Text="MSBuildBinPath $(MSBuildBinPath)" />
<Message Text="MSBuildProjectDefaultTargets $(MSBuildProjectDefaultTargets)" />
<Message Text="MSBuildExtensionsPath $(MSBuildExtensionsPath)" />
@pckujawa
pckujawa / gist:2631963
Created May 8, 2012 01:59
Including the name of the script dynamically, e.g. for a USAGE prompt
USAGE = """
Usage: %s <action> [<action parameters>]
""" % os.path.basename(sys.argv[0])
@pckujawa
pckujawa / gist:2396287
Created April 16, 2012 04:00
Escape the shoebox on android legacy apps
<supports-screens android:largeScreens="true" android:anyDensity="true" />
@pckujawa
pckujawa / gist:2246185
Created March 30, 2012 03:22
android coverflow widget example
/*
* Copyright (C) 2010 Neil Davies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pckujawa
pckujawa / gist:2246183
Created March 30, 2012 03:21
android coverflow widget
/*
* Copyright (C) 2010 Neil Davies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pckujawa
pckujawa / gist:2246120
Created March 30, 2012 03:06
parsing inputs from commandline and creating a latex file from python
from optparse import OptionParser
import os
import re
import subprocess
import sys
parser = OptionParser(usage=__doc__.strip())
parser.add_option('-v', dest='verbose', action='store_true',
help='Verbose output')
@pckujawa
pckujawa / gist:2246101
Created March 30, 2012 03:01
xml parsing using different libraries
################################## 15 ##################################
def hard():
# Example 1
try:
import twisted
help(twisted) # (this may not be as hard as I think, though)
except:
pass
@pckujawa
pckujawa / gist:2246059
Created March 30, 2012 02:54
methods of unit testing in python
# Taken from http://artifex.org/~hblanks/talks/2011/pep20_by_example.html
################################### 7 ##################################
""" Write out the tests for a factorial function. """
#-----------------------------------------------------------------------
def factorial(n):
"""
Return the factorial of n, an exact integer >= 0.