Skip to content

Instantly share code, notes, and snippets.

@uranusjr
uranusjr / installation.rst
Last active August 1, 2021 19:16
在各作業系統上安裝 Python 3.4。

設定 Python 環境

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

Windows

@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 / 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 / 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 / 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 / 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 / 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%
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 / django-tutorial-proposal.txt
Created June 20, 2014 13:51
Django Tutorial Proposal
TITLE: 手把手學 Django
Django 是什麼?
Short Version (不是一節)
Python
Django 的歷史
現在的 Django
我應該學 Django 嗎?
先行技能
Command line 使用技能
@uranusjr
uranusjr / answer.m
Last active September 25, 2019 08:33
Sample implementation of an Objective-C class without Foundation framework.
#import <stdio.h>
#import <stdlib.h>
#import <objc/runtime.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-root-class"
#pragma clang diagnostic ignored "-Wdeprecated-objc-isa-usage"
@interface Answer
{