Skip to content

Instantly share code, notes, and snippets.

View timotheuslin's full-sized avatar

Timothy Lin timotheuslin

  • -
  • Redmond, Washington
View GitHub Profile
@jserv
jserv / pyc.py
Last active March 13, 2021 11:27
import atexit
import ctypes
import os
import shlex
import sys
import tempfile
CMD_C_TO_SO = '{compiler} -shared -o {output} {input} {libraries}'
@golflima
golflima / pyuac.py
Last active July 19, 2025 13:52 — forked from Preston-Landers/pyuac.py
pyuac - elevate a Python process with UAC on Windows - Python3 on Win10
#!/usr/bin/env python
# -*- coding: utf-8; mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vim: fileencoding=utf-8 tabstop=4 expandtab shiftwidth=4
"""User Access Control for Microsoft Windows Vista and higher. This is
only for the Windows platform.
This will relaunch either the current script - with all the same command
line parameters - or else you can provide a different script/program to
run. If the current user doesn't normally have admin rights, he'll be
@Artiomio
Artiomio / keyboard_fly.py
Last active October 11, 2021 11:21
Python Linux/Windows async keyboard library - non-blocking keyboard input - read one character at a time
from __future__ import print_function
try:
import msvcrt
def key_pressed():
return msvcrt.kbhit()
def read_key():
key = msvcrt.getch()
@evertrol
evertrol / Makefiles.md
Last active October 13, 2025 20:52
Makefile cheat sheet

Makefile cheat sheet

Mostly geared towards GNU make

I've used ->| to indicate a tab character, as it's clearer to read than

  • Set a target, its dependencies and the commands to execute in order
target: [dependencies]
->| 
@tos-kamiya
tos-kamiya / WinPDBをPython3のデバッグに使う.md
Last active June 1, 2020 00:56
WinPDBをPython3のデバッグに使う

追記(2017.06.03)

WinPDBのフォークがPython3サポートしてました。こっちを使いましょう。

https://github.com/bluebird75/winpdb

次のように対象プログラムを実行するインタプリタを指定できます。

python -m winpdb -i python3 my_program.py
@benhoyt
benhoyt / atomic_counter.py
Created August 3, 2016 13:12
An atomic, thread-safe incrementing counter for Python
"""An atomic, thread-safe incrementing counter."""
import threading
class AtomicCounter:
"""An atomic, thread-safe incrementing counter.
>>> counter = AtomicCounter()
>>> counter.increment()
@willurd
willurd / web-servers.md
Last active October 26, 2025 20:00
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ozh
ozh / gist:4154909
Created November 27, 2012 15:41
Git trick: have a branch mirror another one

Git post-commit hook to keep master and gh-pages branch in sync :

In your Git repository create a file .git/hooks/post-commit and fill it with this:

#!/bin/sh
git checkout gh-pages
git rebase master
git checkout master
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream