Skip to content

Instantly share code, notes, and snippets.

View freakboy3742's full-sized avatar

Russell Keith-Magee freakboy3742

View GitHub Profile
@freakboy3742
freakboy3742 / app.py
Last active April 19, 2024 04:16
Tutorial 1 - app code
class HelloWorld(toga.App):
def startup(self):
main_box = toga.Box(style=Pack(direction=COLUMN))
name_label = toga.Label(
"Your name: ",
style=Pack(padding=(0, 5))
)
self.name_input = toga.TextInput(style=Pack(flex=1))
@freakboy3742
freakboy3742 / explicit.toml
Last active October 15, 2019 13:19
Inherited properties in TOML
[thing]
name = "demo"
[thing.version_a]
items = ['base1', 'base2', 'first1', 'first2']
[thing.version_b]
items = ['base1', 'base2', 'second1', 'second2']
@freakboy3742
freakboy3742 / hello.py
Created September 29, 2019 17:02
IMessageFilter on Python.net
import clr
clr.AddReference("System.Windows.Forms")
import System.Windows.Forms as WinForms
class MessageFilter(WinForms.IMessageFilter):
__namespace__ = 'System.Windows.Forms'
def PreFilterMessage(self, message):
print('filter', message)
@freakboy3742
freakboy3742 / proxy_problem.js
Created March 7, 2018 01:20
Desperately Seeking JSusan...
class PyType {
constructor(name, bases, dict) {
this.name = name
this.bases = bases
this.dict = dict
}
__str__() {
return this.name
@freakboy3742
freakboy3742 / adhoc nm.log
Last active March 1, 2018 00:17
Symbol stripping in iOS AdHoc builds
Travel Tips (for architecture armv7):
U _CFStringGetCStringPtr
U _NSLog
U _NSSearchPathForDirectoriesInDomains
U _OBJC_CLASS_$_NSBundle
U _OBJC_CLASS_$_NSCharacterSet
U _OBJC_CLASS_$_NSString
U _OBJC_EHTYPE_$_NSException
U _UIApplicationMain
@freakboy3742
freakboy3742 / nested.py
Last active December 5, 2017 01:28
Asyncio
import asyncio
async def stuff(val):
print("Going to sleep for", val)
await asyncio.sleep(val)
print("slept")
return val * 2
def do_stuff():
print("do stuff")
@freakboy3742
freakboy3742 / feedback.rst
Created August 20, 2017 02:43
Dear Hotel RL...

I don't think I've ever stayed at a hotel that has so fundamentally failed at the basic competence of being a hotel.

We arrived at midday, expecting a 3PM checkin. We didn't get into our room until 5PM. Some of our travelling companions didn't get into their room until 10:30PM.

When we did get to our room (a double), the room itself was barely large enough to stand in. There were two beds... but space for bags, etc was extremely limited.

The bathroom was even worse. You couldn't use the facilities without fully closing the door behind you. The room was provided with 1 full size bath towel, and 2 smaller towels. We rang reception for more towels and were delivered... 2 more hand towels.

The coffee facilities (again, for 2 people) consisted of a single coffee pod.

@freakboy3742
freakboy3742 / nabokov.jpg
Last active June 14, 2017 23:58
Emoji Archeology 101
nabokov.jpg
@freakboy3742
freakboy3742 / window.py
Created May 23, 2017 23:26
Winforms menus
from toga.interface.window import Window as WindowInterface
from .libs import *
from .container import Container
from . import dialogs
from .command import SEPARATOR, SPACER, EXPANDING_SPACER
class Window(WindowInterface):
# _IMPL_CLASS = WinForms.Form
@freakboy3742
freakboy3742 / voc_example.py
Last active May 1, 2017 17:15
Abusing Python for fun and profit
from javax.swing import JFrame, JLabel, SwingUtilities
class HelloWorldSwing(implements=java.lang.Runnable):
def run(self) -> void:
self.createAndShowGUI()
def createAndShowGUI(self):
frame = JFrame("HelloWorldSwing")
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)