Skip to content

Instantly share code, notes, and snippets.

View jamesstidard's full-sized avatar

James Stidard jamesstidard

View GitHub Profile
import click
@click.command()
def login():
password = click.prompt('Password: ', hide_input=True)
session_token = ''.join(reversed(password)) # exchange password for session token in some way
click.echo('export MY_SESSION_TOKEN="{}"'.format(session_token))
if __name__ == '__main__':
login()
@jamesstidard
jamesstidard / forgotten-commands.md
Last active January 26, 2021 10:18
A list of terminal commands I always forget because I infrequently need them

Forgotten Commands

git

Remove accidently tracked files/folders from git and keep local.

$ git rm --cached -r <somedir/file/regex>

Undo previous unpushed commits, keeping the changes, for better commit message.

import asyncio
from sanic import Sanic
from sanic.websocket import ConnectionClosed
app = Sanic(__name__)
ws_clients = set()
import asyncio
import websockets
from websockets.exceptions import ConnectionClosed
connected = set()
async def suppress(f, *, exception):
try:
@jamesstidard
jamesstidard / dual_interface.py
Last active September 30, 2016 00:50
Optional asynchronous interface
import asyncio
from functools import wraps
def serializable(f):
@wraps(f)
def wrapper(*args, asynchronous=False, **kwargs):
if asynchronous:
return f(*args, **kwargs)
else:
### Keybase proof
I hereby claim:
* I am jamesstidard on github.
* I am jamesstidard (https://keybase.io/jamesstidard) on keybase.
* I have a public key whose fingerprint is E84F 5927 474F 8A4D 2D7E A7CB 8185 2233 4C89 EE63
To claim this, I am signing this object: