Skip to content

Instantly share code, notes, and snippets.

@uranusjr
uranusjr / configure.diff
Created February 13, 2014 08:27
Patch to remove hard-coded OS X build spec inside the configure script. Homebrew's Qt uses either unsupported-macx-clang-libc++ (Mavericks) or unsupported-macx-clang (10.8 and earlier). Both are find as default, while macx-g++ is not.
diff --git a/configure b/configure
index a1e1f5e..9d5d6e0 100755
--- a/configure
+++ b/configure
@@ -12,7 +12,6 @@ QXT_MODULES="docs berkeley core designer gui network sql web zeroconf"
if uname -a | grep -iq Darwin; then
QXT_MAC=1
DEFAULT_LIBS="/Library/Frameworks"
- QMAKE_PARAMS="-spec macx-g++"
NO_XRANDR=1
@uranusjr
uranusjr / django-tutorial-proposal.txt
Created June 20, 2014 13:51
Django Tutorial Proposal
TITLE: 手把手學 Django
Django 是什麼?
Short Version (不是一節)
Python
Django 的歷史
現在的 Django
我應該學 Django 嗎?
先行技能
Command line 使用技能
if (argc < 2)
{
// Launch normally.
return;
}
NSString *path = [NSString stringWithUTF8String:argv[1]];
path = [path stringByStandardizingPath]; // You should do this, BTW.
if ([[NSFileManager defaultManager] fileExistsAtPath:path])
{
// Open the file.
@uranusjr
uranusjr / Create Prompt Shortcut.bat
Created August 6, 2014 14:55
Create a Command Prompt shortcut with %Path% setup for a particular Python distribution
@echo off
setlocal
set /p PYTHONEXE="Drag and drop python.exe here, and press ENTER: "
for %%d in (%PYTHONEXE%) do set PYTHONROOT=%%~dpd
:: Strip trailing backslash.
set PYTHONROOT=%PYTHONROOT:~0,-1%
@uranusjr
uranusjr / input
Last active August 29, 2015 14:05
Test cases for MathJax support
\\[
1*2*3 multi-line math
\\]
\\( 1*2*3 inline-math \\)
$$ 1*2*3 math with dollar $$
$$ 1*2*3 \$ \\ \text{dollar with escapes} $$
@uranusjr
uranusjr / pythonize.py
Last active August 29, 2015 14:12
Testing black magic
# ↓↓↓ Scroll to bottom for an example. ↓↓↓
import importlib
import pkgutil
def pythonize(qt_package):
proxy = _PackageProxy(qt_package)
return proxy
@uranusjr
uranusjr / create-python-env.vbs
Last active August 29, 2015 14:17
Script to create a shortcut for Python development on Windows (7 or later)
' Requirements:
' * Windows 7 or later. (Might work on Vista; XP is definitely out.)
' * Python 3 installation. (Will prompt for installation path.)
' The installation path should be both readable and *writable*.
Set fs = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")
home = shell.ExpandEnvironmentStrings("%HOMEPATH%")
@uranusjr
uranusjr / gist:02ccb82ff02e5531ef6a
Created March 29, 2015 08:13
Declarative styling inspired by django-crispy-forms
import toga
f_input = toga.TextInput()
c_input = toga.TextInput(readonly=True)
c_label = toga.Label('Celcius', alignment=toga.LEFT_ALIGNED)
f_label = toga.Label('Fahrenheit', alignment=toga.LEFT_ALIGNED)
join_label = toga.Label('is equivalent to', alignment=toga.RIGHT_ALIGNED)
@uranusjr
uranusjr / api.py
Last active August 29, 2015 14:21 — forked from mrjohannchang/api.py
import functools
class Api:
def __init__(self):
self.apis = []
def register(self, f):
self.apis.append(f.__name__)
@uranusjr
uranusjr / accountant.py
Created May 30, 2015 23:48
Starting point for the accountant project.
def _show_items(items):
template = '{name:20}{price:>5}'
if not items:
print("No items. Use 'add' to add some!")
return
print()
print(template.format(name='Item', price='Price'))
print('-' * 25)
for item in items:
print(template.format(