Skip to content

Instantly share code, notes, and snippets.

@courville
courville / tmdb_genres.sh
Created Feb 26, 2021
list all tmdb genres traductions and output result as markdown table
View tmdb_genres.sh
#!/bin/sh
# API= your tmdb API key
# all lang except en
LANG=$(curl -s https://api.themoviedb.org/3/configuration/languages\?api_key=${API} | jq | grep iso_639_1 | sed 's/^.*"iso_639_1": "\([a-z][a-z]\).*$/\1/g' | grep -v en | sort -u)
for lang in $LANG
do
curl -s https://api.themoviedb.org/3/genre/movie/list\?api_key=${API}\&language=${lang} | jq | grep \"name\": | grep -v null | sed 's/^.*"name": "\([^"]*\)"/\1/g' > result-$lang
View opus-build.sh
#!/bin/bash
[ ! -d "opus" ] && git clone https://github.com/xiph/opus.git
# latest cmake and ndk
CMAKE_PATH=$(ls -d ${ANDROID_HOME}/cmake/* | sort -V | tail -n 1)
echo CMAKE_PATH is ${CMAKE_PATH}
NDK_PATH=$(ls -d ${ANDROID_HOME}/ndk/* | sort -V | tail -n 1)
echo NDK_PATH is ${NDK_PATH}
View build.sh
#!/bin/sh
git clone https://github.com/xiph/opus.git
CMAKE_PATH=/opt/android-sdk/cmake/3.10.2.4988404
NDK_PATH=/opt/android-sdk/ndk/21.3.6528147
API_LEVEL=21
for ABI in armeabi-v7a arm64-v8a x86 x86_64
do
View gist:46c7ec0852fd177a87ff9c8d36f47afd
diff --git a/build.sh b/build.sh
index 817c996..c15891b 100755
--- a/build.sh
+++ b/build.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -x
while getopts "a:c:" opt; do
case $opt in
@courville
courville / TestScraper.java
Last active Apr 14, 2020
Test scraper code for Nova Video Player
View TestScraper.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// TODO: add MoviePathMatcher
// TODO: add TvShowPathMatcher
@courville
courville / alertDialogForProgressDialog.java
Created Mar 27, 2020
simple AlertDialog fo replace ProgressDialog which is deprecated
View alertDialogForProgressDialog.java
private AlertDialog alertDialog = null;
private ProgressBar progressBar = null;
private TextView textView = null;
public void displaySimpleDialog(Context context, boolean isSpinner, String dialogText, int progress, int maxProgress) {
if (alertDialog == null) { // init part
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setOnCancelListener(dialog -> {
dialog.cancel();
// do cleaning stuff
@courville
courville / findModeId.java
Last active Feb 3, 2020
find display modeId that matches currentMode resolution and desired refreshRate
View findModeId.java
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();
@courville
courville / iso6391tolanguage.java
Created Feb 1, 2020
two letter ISO639-1 to language conversion
View iso6391tolanguage.java
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 / smallqueries.java
Last active Dec 29, 2021
avoid SQLiteBlobTooBigException: Row too big to fit into CursorWindow
View smallqueries.java
// run small queries
static final int WINDOW_SIZE = 1000;
Cursor cursor = getFileListCursor(PARAM_ALL, null);
final int numberOfRows = cursor.getCount();
cursor.close();
int index = 0;
int window = WINDOW_SIZE;
@courville
courville / m-cursorwindow.diff
Created Jan 3, 2020
fight Row too big to fit into CursorWindow
View m-cursorwindow.diff
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;