Portions taken from http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html (in case that link ever dies.)
Assume you've got homebrew installed.
Download the following files from Oracle
# Simple demo of playing a looping sound using the (currently undocumented) sound.Player class | |
import sound | |
import os | |
from scene import * | |
class MyScene (Scene): | |
def setup(self): | |
self.player = sound.Player(os.path.expanduser('~/Pythonista.app/Beep.caf')) | |
self.player.number_of_loops = -1 #repeat forever |
# sounder.py | |
# play each of the .caf sounds inside the Pythonista.app | |
import os, os.path, scene, sound | |
framesPerSound = 60 | |
pythonistaDir = os.path.expanduser('~/Pythonista.app') | |
soundFileExtension = '.caf' | |
wallpaperAppIcon = ('/AppIcon76x76@2x~ipad.png', '/AppIcon60x60@2x.png') |
'''pipista.py''' | |
import os, os.path, sys, urllib2, requests | |
class PyPiError(Exception): | |
def __init__(self, value): | |
self.value = value | |
def __str__(self): | |
return repr(self.value) |
Portions taken from http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html (in case that link ever dies.)
Assume you've got homebrew installed.
Download the following files from Oracle
See README.md for details. |
def enum(*sequential, **named): | |
enums = dict(zip(sequential, range(len(sequential))), **named) | |
reverse = dict((value, key) for key, value in enums.iteritems()) | |
enums['reverse_mapping'] = reverse | |
return type('Enum', (), enums) | |
def example(): | |
Numbers = enum(ONE=1, TWO=2, THREE='three') | |
print Numbers.ONE | |
print Numbers.THREE |
<?php | |
class JsonSortTest extends PHPUnit_Framework_TestCase { | |
public $fixtureFilename = 'fixture.json'; | |
public $outputFilename = 'output.json'; | |
public $fixtureJson; | |
function ksortObjectsRecursive(&$data, $sortFlags = SORT_REGULAR) { | |
if (!function_exists('ksortObjectsRecursiveCallback')) { | |
function ksortObjectsRecursiveCallback(&$data, $unusedKey, $sortFlags) { |
private function getNewGUID($wrapWithBraces = false) { | |
if (function_exists('com_create_guid')) { | |
return com_create_guid(); | |
} else { | |
mt_srand((double)microtime() * 10000); //optional for php 4.2.0 and up. | |
$charid = strtoupper(md5(uniqid(rand(), true))); | |
$uuid = ($wrapWithBraces ? '{' : '') | |
. substr($charid, 0, 8) . '-' | |
. substr($charid, 8, 4) . '-' | |
. substr($charid, 12, 4) . '-' |
This is a list of tips for the Vim editor
<?php | |
/** | |
* Class ClassUtil | |
* | |
* Provide useful methods to overcome OOP shortcomings in some versions of PHP. | |
*/ | |
class ClassUtil { | |
/** | |
* The "::class" notation isn't available until PHP 5.5. This method is a workaround for | |
* older versions of PHP. |