Skip to content

Instantly share code, notes, and snippets.

@Gro-Tsen
Gro-Tsen / 20190505.android-copy-firefox-profile
Created May 5, 2019 11:00
Possible steps under Android to copy Firefox profile to Firefox Nightly
## FIRST, install Firefox Nightly on Android. Then run it once and let it start.
## Then force stop it and clear its cache (but not further data).
## Then understand the following commands, adapt them, and use them
## (as root through adb).
# Get the original profile name:
cd /data/data/org.mozilla.firefox/files/mozilla
srcsalt="$(echo *.default)"
echo "$srcsalt"
// This code is in the Public Domain.
#include <stdint.h>
#include <string.h>
#include <assert.h>
void
serialize_be_16 (uint8_t b[2], uint16_t w)
{
for ( int i=0 ; i<2 ; i++ )
## Initial attempt:
ffmpeg -loop 1 -i /tmp/schumann-piano-concerto-III-97-to-104.png -i /tmp/schumann-piano-concerto-III-97-to-104.ogg -c:v libx264 -tune stillimage -c:a aac -b:a 192k -shortest /tmp/out.mp4
## Phone doesn't like YUV444 format, so let's try this:
ffmpeg -loop 1 -i /tmp/schumann-piano-concerto-III-97-to-104.png -i /tmp/schumann-piano-concerto-III-97-to-104.ogg -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest /tmp/out.mp4
## Still not happy. Change framerate, audio bitrate and scale, perhaps?
ffmpeg -r 25 -loop 1 -i /tmp/schumann-piano-concerto-III-97-to-104.png -i /tmp/schumann-piano-concerto-III-97-to-104.ogg -c:v libx264 -tune stillimage -ar 48000 -c:a aac -b:a 96k -vf scale=1280:260 -pix_fmt yuv420p -shortest /tmp/schumann-piano-concerto-III-97-to-104.mp4
## Apparently, Twitter also worries about the aspect ratio:
## The vector space in which everything will happen:
V = QQ^8
## The simple roots (and smallest root alpha0) of E_8 under the usual “even”
## coordinate system:
alpha1 = V((1,-1,-1,-1,-1,-1,-1,1))/2
alpha2 = V((1,1,0,0,0,0,0,0))
alpha3 = V((-1,1,0,0,0,0,0,0))
alpha4 = V((0,-1,1,0,0,0,0,0))
alpha5 = V((0,0,-1,1,0,0,0,0))
## Find numbers n which have a good score sigma(n)/(n*log(log(n))):
## see https://twitter.com/johncarlosbaez/status/1149700802371608576
## Prime factorization of 2520:
bootstrap = {2: 3, 3: 2, 5: 1, 7: 1}
## Compute the score sigma(n)/(n*log(log(n))) from the prime factorization:
def goodness(d):
n = prod([p^(d[p]) for p in d.keys()])
sig = prod([(p^(d[p]+1)-1)/(p-1) for p in d.keys()])
double
uniform (void)
// Return a uniformly distributed random variable between 0 and 1.
{
#define ENTROPY_PER_RAND 31
#if RAND_MAX != (1<<ENTROPY_PER_RAND)-1
#error Please fix ENTROPY_PER_RAND
#endif
int entropy = 0;
double val = 0.5;
for i in $(seq 0 9) ; do convert -size 960x720 'xc:gray' -font 'FreeSans' -pointsize 200 -gravity Center -annotate 0 $i frame${i}.png ; done
for i in $(seq 0 9) ; do echo "file frame${i}.png" ; echo "duration 6.000" ; done > video.script
sox -n -r 48000 -c 2 -t flac silence.flac trim 0.0 60.0
ffmpeg -f concat -i video.script -i silence.flac -c:v libvpx -crf 12 -pix_fmt yuv420p -c:a libopus -b:a 192k test.webm
@Gro-Tsen
Gro-Tsen / override.xml
Created May 15, 2019 13:23
Fix for DjVu files being detected as MIME type image/vnd.djvu instead of image/vnd.djvu+multipage
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<!-- Created on 2019-05-15 to fix a reappearance of this bug: -->
<!-- https://bugs.launchpad.net/ubuntu/+source/djvulibre/+bug/1778088 -->
<!-- (DjVu seen as image/vnd.djvu instead of image/vnd.djvu+multipage) -->
<!-- https://twitter.com/gro_tsen/status/1128645721614356480 -->
<!-- Run "update-mime-database ~/.local/share/mime" after creating this. -->
<!-- Use "xdg-mime query filetype some-file.djvu" to test. -->
<!-- - David A. Madore -->
<mime-type type="image/vnd.djvu+multipage">
  • Sans abonnement 23.40€/h ; location « mise en pause » à 7.80€/h

  • Tarif journée (≥4h) existe peut-être, introuvable sur le site

  • Renault Zoe (23.40€/h) ou Twizy (17.40€/h)

  • Dépôt de garantie (500€) ; état des lieux

### Speed up ×6:
ffmpeg -f concat -safe 0 -i =(for file in /mnt/ext/data/100GOPRO/GH??0012.MP4 ; do echo file $file ; done) -vf select='eq(mod(n\,25)\,0)+eq(mod(n\,25)\,6)+eq(mod(n\,25)\,12)+eq(mod(n\,25)\,18)',scale=960:540,setpts=N/24/TB,fps=24 -c:v libx264 -crf 26 -an /tmp/timelapse-combined/tl-gopro.mp4 ; done
ls /mnt/usbkey/AUKEY/Movie/2019_0915_*B.MP4 | perl -ne 'print "$1\n" if m/(2019_0915_[0-9]{6}_[0-9]{3}B\.MP4)/' > /tmp/filelist
for f in $(cat /tmp/filelist) ; do ffmpeg -i "/mnt/usbkey/AUKEY/Movie/${f}" -vf select='(eq(mod(n\,15)\,0)+eq(mod(n\,15)\,7))*lt(n\,5400)',scale=960:540,setpts=N/24/TB,fps=24 -c:v libx264 -crf 26 -an /tmp/timelapse-combined/tl-dashcam-${f%.MP4}.mp4 ; done
## I have no idea why this causes errors
# convert 'xc:gray[960x540!]' /tmp/timelapse-combined/gray.png
# ffmpeg -r 24 -f concat -safe 0 -i =(for i in $(seq 1349) ; do echo file /tmp/timelapse-combined/gray.png ; done) -c:v libx264 -an -pix_fmt yuv420p /tmp/timelapse-combined/gray.mp4