Skip to content

Instantly share code, notes, and snippets.

@courville
courville / domoticz-closerollershutters.sh
Last active January 4, 2019 14:03
update domoticz scene timer to close roller shutters at dusk but not before 8pm and not after 10pm at Paris location
#!/bin/sh
#
# domoticz-closerollershutters
# use sunwait to get civil dusk time to calculates when to close roller shutters with the constraints to be in this interval >20h <22h, civildusk i.e. min(max(civildusk,20h),22h)
tdusk=`/usr/local/bin/sunwait -p 48.866667N 2.333333W | grep "Sun rises" | sed "s/^.* sets \([0-9]*\) .*$/\1/g"`
hdusk=`echo $tdusk | cut -c 1-2`
mdusk=`echo $tdusk | cut -c 3-4`
sdusk=`date -d"$hdusk:$mdusk" +%s`
notbefore=`date -d"20:00" +%s`
@courville
courville / fixsambamangled.sh
Created January 4, 2019 14:07
fix filenames to avoid samba client name mangling
find . -type f -name \*"[\*\?\:<>\\\"\|]"\* -print0 | xargs -0 rename -v 's/[\*\?\:<>\\\"\|]/_/g'
@courville
courville / adbdate.sh
Created January 4, 2019 14:10
force date and time via adb based on host result
adb shell su root date -u @$(date -u +%s)
@courville
courville / sadb.sh
Created January 4, 2019 14:12
adb connect on a chromebook crostini container to android
adb connect 100.115.92.2:5555
@courville
courville / SurfaceController.java.diff
Created December 10, 2019 17:27
SurfaceController.java.diff
diff --git a/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java b/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java
index 089df18..4ebd723 100644
--- a/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java
+++ b/src/main/java/com/archos/mediacenter/video/player/SurfaceController.java
@@ -20,6 +20,7 @@ import com.archos.medialib.IMediaPlayer;
import android.graphics.SurfaceTexture;
import android.opengl.GLSurfaceView;
+import android.os.Build;
import android.util.Log;
@courville
courville / a.diff
Created December 12, 2019 08:50
attempt scale to fit with crop for good aspect ratio on amlogic
diff --git a/external/android/libsfdec/sfdec_ndkmediacodec.cpp b/external/android/libsfdec/sfdec_ndkmediacodec.cpp
index 57f6c7e..6c14586 100644
--- a/external/android/libsfdec/sfdec_ndkmediacodec.cpp
+++ b/external/android/libsfdec/sfdec_ndkmediacodec.cpp
@@ -19,7 +19,7 @@
#ifdef __ANDROID_API__
#undef __ANDROID_API__
-#define __ANDROID_API__ 21
+#define __ANDROID_API__ 26
@courville
courville / a-no_init_renderer.diff
Created December 13, 2019 14:06
avos: do not apply MediaCodec AR
diff --git a/external/android/libsfdec/sfdec_ndkmediacodec.cpp b/external/android/libsfdec/sfdec_ndkmediacodec.cpp
index 57f6c7e..56752c0 100644
--- a/external/android/libsfdec/sfdec_ndkmediacodec.cpp
+++ b/external/android/libsfdec/sfdec_ndkmediacodec.cpp
@@ -76,12 +76,12 @@ static int init_renderer(sfdec_priv_t *sfdec)
if (format != NULL) {
if (AMediaFormat_getInt32(format, "width", &width)) {
- LOG("width changed: %d -> %d", sfdec->width, width);
- sfdec->width = width;
@courville
courville / m-cursorwindow.diff
Created January 3, 2020 07:53
fight Row too big to fit into CursorWindow
diff --git a/src/com/archos/mediascraper/AutoScrapeService.java b/src/com/archos/mediascraper/AutoScrapeService.java
index 256242c..4115703 100644
--- a/src/com/archos/mediascraper/AutoScrapeService.java
+++ b/src/com/archos/mediascraper/AutoScrapeService.java
@@ -22,8 +22,12 @@ import android.app.Service;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
+import android.database.AbstractWindowedCursor;
import android.database.ContentObserver;
@courville
courville / iso6391tolanguage.java
Created February 1, 2020 11:53
two letter ISO639-1 to language conversion
String language_iso_639_1 = "fr";
if (language_iso_639_1 != null) {
Locale locale = new Locale(language_iso_639_1);
String language = locale.getDisplayLanguage());
}
@courville
courville / findModeId.java
Last active February 3, 2020 21:26
find display modeId that matches currentMode resolution and desired refreshRate
if (Build.VERSION.SDK_INT >= 23) {
Display.Mode[] supportedModes = d.getSupportedModes();
Display.Mode currentMode = d.getMode();
// calculate wantedFps
float wantedFps = (float) ((double) video.fpsRate / (double) video.fpsScale);
int wantedModeId = 0;
// find corresponding wantedModeId for wantedFps
for (int i = 0; i < supportedModes.length; i++) {
if (supportedModes[i].matches(currentMode.getPhysicalWidth(), currentMode.getPhysicalHeight(), wantedFps)) {
wantedModeId = supportedModes[i].getModeId();