Skip to content

Instantly share code, notes, and snippets.

View paulproteus's full-sized avatar

Asheesh Laroia paulproteus

View GitHub Profile
@paulproteus
paulproteus / MainActivity.kt
Created July 12, 2020 03:02
Android/Kotlin activity with Password input
package org.asheesh.bottomnavigationactivity
import android.os.Bundle
import android.text.InputType
import android.text.method.PasswordTransformationMethod
import android.view.Gravity
import android.view.View
import android.widget.EditText
import android.widget.RelativeLayout
import android.widget.TextView
@paulproteus
paulproteus / Performance notes.md
Last active June 30, 2020 02:29
Performance notes for BeeWare/Android/Python

Current performance worries

  • Unpacking stdlib is very slow. See "things that look promising" below.

  • There's a somewhat sad trade-off between disk I/O being slow on one hand, and bytecode-compiling PYCs being slow on the other.

Things I tried that look promising:

  • If you put the Python *.so modules in the jniLibs directory, then you can add it to PYTHONPATH, ignore PYTHONHOME, and import the libs straight from jnilibs-land. Not bad.
@paulproteus
paulproteus / backup.sh
Last active June 21, 2020 07:17
backup a volume
#!/bin/bash
set -eou pipefail
blockdev="$1"
name="$2"
TMP="$(mktemp -d /tmp/$(date -I).$2.XXXXXXXXXX )"
FILELIST="$TMP"/"$name".filelist.txt
# Make the blockdev available in /tmp/name
@paulproteus
paulproteus / output.txt
Created June 16, 2020 20:51
Happy briefcase run android output
$ briefcase run android -d @beePhone
[helloworld2] Generating application template...
Using app template: https://github.com/beeware/briefcase-android-gradle-template.git
Using existing template (sha 158d51d33468f2df9eb60445beb7cd9bf7312d87, updated Sat Jun 13 17:14:26 2020)
[helloworld2] Installing support package...
Using support package https://briefcase-support.org/python?platform=android&version=3.7
... using most recent revision
Python-3.7-Android-support.b4.zip already downloaded
@paulproteus
paulproteus / README.md
Last active June 16, 2020 05:57
TCP asyncio hello world

Look at this TCP hello world video

@paulproteus
paulproteus / macOS terminal notifications, delayed, etc.md
Created June 16, 2020 04:28
macOS terminal notifications, delayed, etc.
echo terminal-notifier -message alttab -open https://github.com/lwouis/alt-tab-macos/issues/376 | at now + 20 minutes
06-14 18:26:07.329 5258 5276 D stdio : Starting to capture stdout/stderr to Android log.
06-14 18:26:07.329 5258 5276 D stdio : stdout now successfully routes into the stdio logger.
06-14 18:26:08.615 5258 5276 D stdio : Start Python runtime...
06-14 18:26:08.616 5258 5276 D stdio : Initializing Python runtime...
06-14 18:26:08.821 5258 5276 D stdio : Initializing Python threads...
06-14 18:26:08.821 5258 5276 D stdio : Import rubicon...
06-14 18:26:10.685 5258 5276 D stdio : Python app launched & stored in Android Activity class
06-14 18:26:10.874 5258 5276 D stdio : Toga app: onCreate
06-14 18:26:10.894 5258 5276 D stdio : Toga app: onStart
06-14 18:26:10.899 5258 5276 D stdio : Toga app: onResume
@paulproteus
paulproteus / log.txt
Created June 14, 2020 04:52
Hello World w/ Android event loop log
06-13 21:51:17.821 4372 4389 D stdio : Starting to capture stdout/stderr to Android log.
06-13 21:51:17.822 4372 4389 D stdio : stdout now successfully routes into the stdio logger.
06-13 21:51:19.086 4372 4389 D stdio : Start Python runtime...
06-13 21:51:19.112 4372 4389 D stdio : Initializing Python runtime...
06-13 21:51:19.351 4372 4389 D stdio : Initializing Python threads...
06-13 21:51:19.351 4372 4389 D stdio : Import rubicon...
06-13 21:51:19.359 4372 4389 D stdio : Rubicon namespace package not registered!
06-13 21:51:22.302 4372 4389 D stdio : Python app launched & stored in Android Activity class
06-13 21:51:22.320 4372 4389 D stdio : Started event loop
06-13 21:51:22.320 4372 4389 D stdio : Doing call_later on
@paulproteus
paulproteus / Python-3.6-Android.md
Last active June 13, 2020 19:29
Python 3.6 on Android notes

OK, so I've got it built.

  • Is OpenSSL OK?
    • Looks like no -- should probably check this out
  • Fix my OpenSSL patch to apply, unless I should do it at runtime (?) - don't, b/c runtime is slow.
  • Is libxz OK?
    • Looks OK -- we have ./lib/python3.6/lib-dynload/_lzma.cpython-36m.so
  • Is sqlite OK?
    • Looks OK -- we have ./lib/python3.6/lib-dynload/_sqlite3.cpython-36m.so
  • Is ctypes OK?
@paulproteus
paulproteus / select_example.c
Created June 10, 2020 19:38
Select on a file
#include <stdio.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/select.h>
int main(void) {
int read_fd = open("example.txt", O_NONBLOCK | O_RDONLY);