Skip to content

Instantly share code, notes, and snippets.

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 / install_ensurepip.py
Created August 22, 2014 02:44
Script to install ensurepip to Python. “Fix” the Ubuntu 14.04 / Debian Sid bug. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732703
import os
import sys
import io
import tarfile
import urllib.request
ARCHIVE_URL = 'http://d.pr/f/YqS5+'
@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 / installation.rst
Last active August 1, 2021 19:16
在各作業系統上安裝 Python 3.4。

設定 Python 環境

開始使用 Pyhton 之前,首先要確定電腦上能不能執行 Pyhton 程式。本教學將需要 Python 3.4 或更高的版本,因此請確認電腦上是否有對應版本。若不確定電腦上是否已經安裝 Python,建議直接按照以下步驟設定,以保證教學中的程式皆能夠正常執行。由於各作業系統安裝流程不同,以下請按照作業系統,選擇自己需要的部份閱讀。

Windows

@uranusjr
uranusjr / create-env.vbs
Last active September 16, 2018 16:49
Django Girls Taipei 專用 Windows 環境設定程式。需要 Windows 7 以上。若你使用 Windows Vista 或更舊的版本,請聯絡助教。
' Requirements:
' * Windows 7 or later. (Might work on Vista and XP.)
' * Python 3 installation. (Will prompt for installation path.)
' The installation path should be both readable and *writable*.
' * msysGit installation.
Function GetPath(ByVal prompt)
' Collect path.
path = InputBox(prompt)
@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__)