Skip to content

Instantly share code, notes, and snippets.

View pfmaggi's full-sized avatar

Pietro F. Maggi pfmaggi

View GitHub Profile
@pfmaggi
pfmaggi / screenshot.sh
Created September 2, 2014 18:31
Capturing screenshot images from Android devices through ADB
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
@pfmaggi
pfmaggi / Git_pieces.md
Last active February 11, 2016 13:40
Git bits and Pieces

Create a tag and push it to remote

First we can list the current tags

git tag

Then we create a new tag

git tag <tag_name>
python -m SimpleHTTPServer 8080

If you want to only serve on localhost you'll need to write a custom Python program such as:

import sys
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
@pfmaggi
pfmaggi / MyWorkTest.kt
Created March 20, 2019 15:56
Sample implementation for testing CoroutineWorker from the WorkManager library
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pfmaggi
pfmaggi / ffmpeg-build.sh
Created March 20, 2019 19:39
ffmpeg-build.sh - glinux version
#!/bin/bash
if [ -z "$ANDROID_NDK" ]; then
echo "Please set ANDROID_NDK to the Android NDK folder"
exit 1
fi
#Change to your local machine's architecture
# HOST_OS_ARCH=darwin-x86_64
HOST_OS_ARCH=linux-x86_64
@pfmaggi
pfmaggi / gist:898f97a5026821f8a54baaa4c3751563
Created August 25, 2019 08:53 — forked from TobiasWooldridge/gist:22f0cdca75190b9a473f
How to Unbrick a Kindle Paperwhite

How to unbrick an Amazon Kindle Paperwhite™

This guide instructs you in how to unbrick an Amazon Kindle Paperwhite. The consequences of following it are your own responsibility. This method (opening the Kindle and using the serial interface) should be a last resort and should only be considered if other methods fail

The Guide

  1. Pry open Kindle using a prying tool
  2. Unscrew the screen and remove it from the base. Note that there's a screw hidden under the adhesive at the top in the middle
  3. Solder tin wire to serial ports on the bottom
  4. Attach tin wire to USB TTY device (order is ground, RX, TX, from the kindle's perspective, where GND is the smallest pad) and plug USB TTY device into your computer
  5. Open Putty on your computer in serial mode, with the serial port specified as your USB device and baud configured to 115200
@pfmaggi
pfmaggi / UpvoteStoryWorker.kt
Last active April 1, 2020 12:40
Code for the Medium article: "Customizing WorkManager"
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class UpvoteStoryWorker(
appContext: Context,
workerParams: WorkerParameters,
private val service: UpvoteStoryHttpApi)
: CoroutineWorker(appContext, workerParams) {
override suspend fun doWork(): Result {
@pfmaggi
pfmaggi / AndroidManifest.xml
Last active March 31, 2020 16:03
Code for the Medium article: "Customizing WorkManager"
<!-- Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
<application
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
tools:node="remove" />
</application>
@pfmaggi
pfmaggi / MyWorkerFactory.kt
Last active April 19, 2021 08:48
Code for the Medium article: "Customizing WorkManager"
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class MyWorkerFactory(private val service: UpvoteStoryHttpApi) : WorkerFactory() {
override fun createWorker(
appContext: Context,
workerClassName: String,
workerParameters: WorkerParameters
): ListenableWorker? {
// This only handles a single Worker, please don’t do this!!
@pfmaggi
pfmaggi / MyApplication.kt
Created March 31, 2020 16:27
Code for the Medium article: "Customizing WorkManager"
/* Copyright 2020 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
class MyApplication : Application(), Configuration.Provider {
override fun getWorkManagerConfiguration(): Configuration =
Configuration.Builder()
.setMinimumLoggingLevel(android.util.Log.DEBUG)
.setWorkerFactory(MyWorkerFactory(DesignerNewsService))
.build()
...
}