Skip to content

Instantly share code, notes, and snippets.

View rayworks's full-sized avatar
:atom:

rayworks rayworks

:atom:
  • Shanghai, China
  • 17:20 (UTC +08:00)
View GitHub Profile
@rayworks
rayworks / android-wait-for-emulator.sh
Created June 26, 2024 02:57
CI scripts in GitHub workflow
#!/bin/bash
adb wait-for-device
A=$(adb shell getprop sys.boot_completed | tr -d '\r')
while [ "$A" != "1" ]; do
sleep 2
A=$(adb shell getprop sys.boot_completed | tr -d '\r')
done
@rayworks
rayworks / mp4-chunk-test.js
Created November 1, 2022 06:29 — forked from icodeforlove/mp4-chunk-test.js
Simple file server test for video
/*jshint node:true*/
var fs = require('fs'),
http = require('http'),
path = require('path'),
port = 1338,
dir = '.';
http.createServer(function (request, response) {
var filePath = path.join(dir, path.basename(request.url));
if (path.extname(request.url) !== '.mp4' || !fs.existsSync(filePath)) return throw404();
@rayworks
rayworks / apply maven-publish
Last active June 26, 2024 02:44
The script to deploy Android aar files to maven repository
apply plugin: 'maven-publish'
// https://developer.android.google.cn/studio/build/maven-publish-plugin
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing {
publications {
@rayworks
rayworks / gist:89a6fb719c0a9aa53c25f09691b97b4f
Last active October 20, 2020 09:42
Prints Caller function names
fun printCallerContextInfo(cb: () -> String, levelDepth : Int = 7) {
if (!BuildConfig.DEBUG)
return
val stackTrace = Thread.currentThread().stackTrace
var i = 0
val builder = StringBuilder()
builder.append("${cb.invoke()} : ")
for (ste in stackTrace) {
i++
@rayworks
rayworks / CompatibleSSLSockFactory.java
Created July 21, 2020 10:39
The compatible version of SSLSocketFactory for resolving SNI issue when using library android-async-http with version 1.4.x
import android.util.Log;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
@rayworks
rayworks / main.dart
Last active January 8, 2020 12:10 — forked from collinjackson/main.dart
Demonstrates scrolling a focused widget into view
// Copyright 2017, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
/// A widget that ensures it is always visible when focused.
@rayworks
rayworks / gist:69b8bb7720b46baa11ffb18b98161496
Last active December 5, 2019 03:31
Foreground DownloadService
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@rayworks
rayworks / gist:15ba92c2e93bc6b4d6270d52942313e3
Last active October 28, 2021 15:21
ffmpeg in practice
1. Compile configure
configuration: --enable-libass --enable-gpl --enable-libfreetype --enable-libvpx --enable-libx264 --enable-libmp3lame
--enable-libspeex --enable-libx265 --enable-nonfree --enable-videotoolbox --enable-audiotoolbox --enable-fontconfig
--enable-libfdk-aac
2. Add subtitles(字幕)
./ffmpeg -i input.mp4 -vf subtitles=your.srt output.mp4
3. Specify subtitles when playing the video
./ffplay -vf subtitles=your.srt input.mp4

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@rayworks
rayworks / gist:428409347a4e1c69ab764da1b60856c8
Created February 2, 2019 05:46
Commands for screen recording and media convertion
adb shell screenrecord --time-limit 3 --bit-rate 2000000 --verbose /sdcard/demo.mp4
ffmpeg -ss 00:00:00.000 -i ./demo.mp4 -pix_fmt rgb24 -r 3 -s 270x480 -t 00:00:3.000 output.gif