Skip to content

Instantly share code, notes, and snippets.

View creallfluharty's full-sized avatar

creallfluharty

  • Columbia, MO
View GitHub Profile
@creallfluharty
creallfluharty / get_android_sdk.md
Last active November 7, 2020 21:50
Install the Android SDK on Linux

1. Download the latest version of the android command line tools (https://developer.android.com/studio#downloads)

$ wget https://dl.google.com/android/repository/commandlinetools-<OS>-<version>_latest.zip

Note: Since you'll need to check the downloads page to get the latest version, you might as well download it there. Using wget is more useful when writing scripts.

2. Extract the tools into a folder which will hold the rest of the SDK

"""
Python implementation of the `which` program. (Searches $PATH for the first file with a given name)
"""
from typing import List, Iterator
from os import environ as env
from operator import methodcaller
import os
@creallfluharty
creallfluharty / parameterized_expand.py
Last active January 9, 2020 04:15
Toy parameterized.expand
def expand(call_args_list):
""" Replaces method m with (completed) partials m_0(*call_args[0]), m_1(*call_args[1]), ... m_{n}(*call_args[n])
ie
```
class TestX:
@expand([
['a', 1],
['b', 2],
])
def asdf(letter, number):
@creallfluharty
creallfluharty / get_magic_out.py
Last active January 9, 2020 04:15
Get IPython magic command output
import io
from contextlib import redirect_stdout
from typing import Optional
from IPython.core.interactiveshell import InteractiveShell #just for the type annotation
from IPython.core.magic import register_line_magic
@register_line_magic # so that we can optionally use get_magic_out as a magic command
def get_magic_out(command: str, ipy: Optional[InteractiveShell]=None) -> str:
""" Redirects the stdout of a ipython magic command to a temporary buffer
Args:
@creallfluharty
creallfluharty / github_desktop_linux_install.sh
Last active February 19, 2021 15:51
Easy installation of github desktop on Ubuntu Linux
pushd $(mktemp -d)
curl -L https://github.com/shiftkey/desktop/releases/download/release-2.1.0-linux1/GitHubDesktop-linux-2.1.0-linux1.deb --output github-desktop.deb
sudo apt install -f ./github-desktop.deb
popd
import io
import requests
from PIL import Image
from itertools import chain
BIGCHUNK_CHUNK_WIDTH = 15
CHUNK_PIXEL_WIDTH = 64
BYTE_BIT_SIZE = 8
COLOR_BIT_SIZE = 4
CHUNK_BYTE_SIZE = int((CHUNK_PIXEL_WIDTH ** 2) * (COLOR_BIT_SIZE / BYTE_BIT_SIZE))
#!/usr/bin/env python3
import fcntl, sys, termios
tty_path = sys.argv[1]
with open(tty_path, 'wb') as tty_fd:
for line in sys.stdin.buffer:
for byte in line:
fcntl.ioctl(tty_fd, termios.TIOCSTI, bytes([byte]))