Skip to content

Instantly share code, notes, and snippets.

View AstraLuma's full-sized avatar
🐍
snek snek snek snek

Jamie Bliss AstraLuma

🐍
snek snek snek snek
View GitHub Profile
@AstraLuma
AstraLuma / helloworld.py
Last active April 16, 2018 19:32
Async Talk Code Examples
import asyncio
async def say(what, when):
await asyncio.sleep(when)
print(what)
# print() is already buffered by Python, IPC Pipes, etc
# You should still async it, but it's only going to bite
# when other things go wrong.

Keybase proof

I hereby claim:

  • I am astronouth7303 on github.
  • I am astraluma (https://keybase.io/astraluma) on keybase.
  • I have a public key ASAryKyuDpM03VLlWyWLGP3dG8ItyZH0Q77LV0yyAKpuKwo

To claim this, I am signing this object:

@AstraLuma
AstraLuma / simplepyz.py
Created October 18, 2018 21:29
Simple zipapp maker
#!/usr/bin/env python3
"""
A little script to make minimal pyz packages for zipsafe programs.
NOTE: zip safe means:
* No package expects to be able to use open() to access data it shipped with
* No compiled modules
"""
import argparse
import os
@AstraLuma
AstraLuma / README.md
Last active December 10, 2018 01:52
Python Async+SSH

Proof of Concept of using Python+Async to connect to a server over SSH.

Requires:

  • Python >= 3.6
  • msgpack
  • tornado<5

Run client.py, assumes you're running ssh-server on localhost and that you can log in to it.

@AstraLuma
AstraLuma / fails1.py
Created March 13, 2019 20:55
Gio Weirdness
import functools
from gi.repository import GObject
from gi.repository import Gio
from gi.repository import GLib
def runloop(func):
@functools.wraps(func)
def wrapped(*pargs, **kwargs):
func(None)
import collections.abc
import pathlib
__all__ = ('root',)
class AttrsView(collections.abc.KeysView):
def __init__(self, root):
self._root = pathlib.Path(root)
@AstraLuma
AstraLuma / 99-phonebackup.rules
Created March 16, 2019 18:25
Automatic Phone Backup (via udev and systemd)
ACTION=="add", ENV{ID_SERIAL}=="*?", RUN+="/home/astraluma/udev-handler"
@AstraLuma
AstraLuma / README.md
Last active August 5, 2019 02:55
How to make a chrome "app"
@AstraLuma
AstraLuma / README.md
Last active August 28, 2019 19:14
Importable GraphQL

The basic idea: Define GraphQL queries as importable modules.

For example:

# queries.gql
#!starwars

query HeroForEpisode($ep: Episode!) {
 hero(episode: $ep) {
#!/usr/bin/python3
import enum
import dataclasses
import struct
import asyncio
import weakref
class InvalidPacket(Exception):
"""