Skip to content

Instantly share code, notes, and snippets.

View paulproteus's full-sized avatar

Asheesh Laroia paulproteus

View GitHub Profile
@paulproteus
paulproteus / known-issues-of-beeware-android.md
Last active June 10, 2020 05:59
Known issues of beeware/briefcase Android tooling

On Android, Toga probably has problems if you rotate the screen. We're probably assuming the activitySingleton never changes. Or... maybe we don't? Anyway, worth figuring this out.

See Ch. 5 (Looper/Handler) of Android Concurrency by G. Blake Meike.

Sometimes one needs to uninstall the app, then reinstall it, for it to really update. I think this has to do with us being careless about app keys, and not really detecting the error condition.

@paulproteus
paulproteus / README.md
Last active June 5, 2020 20:35
ThinkPad Ultrabay Slim HDD adapter, 62P4553 62P4552

I used to use this Ultrabay Slim HDD adapter, but I don't anymore. I'd love to give it to you if you want it!

FRU part number 62P4553 / assembly part number 62P4552

It also has a 40GB fully working (tested) 2.5" IDE hard drive, FRU part number 39T2521 (assembly part number 39T2520).

The IDE hard drive is in a drive sled that makes it easy to add/remove from the Ultrabay Slim adapter.

Free to a good home, plus $5 for shipping to the USA (if you're international, ask and I can give you an estimate). Email me ([email protected]) or contact me at https://forum.thinkpads.com/viewtopic.php?f=11&t=130758&p=846065#p846065

@paulproteus
paulproteus / launchlog.txt
Created June 5, 2020 05:23
Launch timing log
➜ helloworld git:(master) /Users/asheesh/.briefcase/tools/android_sdk/platform-tools/adb logcat -s 'org.beeware.android.MainActivity.appLaunch'
--------- beginning of system
--------- beginning of crash
--------- beginning of main
06-04 22:21:58.201 8177 8177 D org.beeware.android.MainActivity.appLaunch: onCreate() start
06-04 22:21:58.413 8177 8177 D org.beeware.android.MainActivity.appLaunch: startPython() start
06-04 22:21:58.413 8177 8177 D org.beeware.android.MainActivity.appLaunch: unpackPython() start
06-04 22:21:58.413 8177 8177 D org.beeware.android.MainActivity.appLaunch: Unpacking Python with ABI x86 to /data/user/0/org.ash_eesh.helloworld/files/python/stdlib
06-04 22:22:00.652 8177 8177 D org.beeware.android.MainActivity.appLaunch: Unpacking rubicon-java to /data/user/0/org.ash_eesh.helloworld/files/python/rubicon-java
06-04 22:22:00.666 8177 8177 D org.beeware.android.MainActivity.appLaunch: Unpacking Python assets to base dir /data/user/0/org.ash_eesh.helloworld/files/python/user_co
@paulproteus
paulproteus / Faster disk erase.txt
Last active June 5, 2020 19:52
Faster disk erase
openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero | pv -pterb -s $(blockdev --getsize64 /dev/sdb) | sudo dd bs=4M of=/dev/sdb
Thanks to https://serverfault.com/questions/6440/is-there-an-alternative-to-dev-urandom/415962
Note per https://tches.iacr.org/index.php/TCHES/article/view/8392 it may not be as secure as one might dream, but I'm OK with this given my use.
This lets me write to the disk at 128MiB/s, which is better than the ~20MiB/s I was getting when doing the naive
cat /dev/urandom | pv | sudo dd of=/dev/sdb
@paulproteus
paulproteus / Upload a 3TB block device straight to GDrive.txt
Last active May 26, 2020 01:57
Upload a 3TB block device straight to GDrive
https://github.com/labbots/google-drive-upload
+ patch out some `-f` checks to be `-e` (since `-f` is false on a block device)
+ replace `wc -c` with `blockdev --getsize64 $filename` to avoid spending 6 hours on `wc -c` before even uploading
+ `cp -a` the block device to /tmp/ with a nice filename, so google-drive-upload uses that as the GDrive filename
Wait 6 hours or so.
Then figure out the MD5 thing to validate the upload.
@paulproteus
paulproteus / log.txt
Created May 16, 2020 22:55
Logs on app startup without any infinite loop checking in NumberInput on Android
05-16 15:52:01.587 10790 10817 D stdio : Rubicon namespace package not registered!
05-16 15:52:02.994 10790 10817 D stdio : Python app launched & stored in Android Activity class
05-16 15:52:02.996 10790 10817 D stdio :
05-16 15:52:03.097 10790 10817 D stdio : Seems to have a loop for None
05-16 15:52:03.097 10790 10817 D stdio : letting it continue anyway
05-16 15:52:03.100 10790 10817 D stdio : Would have caught loop in set_value(), but continuing anyway
05-16 15:52:03.103 10790 10817 D stdio : Seems to have a loop for None
05-16 15:52:03.103 10790 10817 D stdio : letting it continue anyway
05-16 15:52:03.103 10790 10817 D stdio : Would have caught loop in set_value(), but continuing anyway
05-16 15:52:03.105 10790 10817 D stdio : Seems to have a loop for None
// SNIPPET
// Create a Spinner
val spinner = Spinner(this, Spinner.MODE_DROPDOWN)
val adapter = ArrayAdapter(this, android.R.layout.simple_spinner_item,
arrayOf("Option 1", "Option 2", "Option 3"))
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinner.adapter = adapter
spinner.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
val spinnerParams = RelativeLayout.LayoutParams(spinner.measuredWidth, spinner.measuredHeight)
dynamicLayout.addView(spinner, spinnerParams)
@paulproteus
paulproteus / CustomSpinnerAdapter.kt
Created May 12, 2020 04:18
A weirdo spinner I suppose
package org.asheesh.fourbuttonsattwohundredpixels
import android.database.DataSetObserver
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.SpinnerAdapter
import android.widget.TextView
class CustomSpinnerAdapter: SpinnerAdapter {
Minor layout bug
@paulproteus
paulproteus / app.py
Created May 11, 2020 02:34
HelloWorld toga/beeware app on Android
"""
My first application
"""
import toga
from toga.constants import RIGHT
from toga.style import Pack
from toga.style.pack import COLUMN, ROW