Skip to content

Instantly share code, notes, and snippets.

@tslamic
tslamic / adapt.sh
Created August 10, 2023 11:20
Encodes and segments an MP4 video for adaptive streaming over various network conditions.
#!/bin/bash
# Encodes and segments an MP4 video for adaptive streaming over various network conditions.
# It supports resolutions ranging from 360p to 1080p and creates both HLS and MPEG-DASH playlists.
# Assumes ffmpeg is installed and in the path. Usage: ./encode.sh <video_file>
set -euo pipefail
if [ -z "$1" ]; then
echo "Usage: $0 <video_file>"
@tslamic
tslamic / api.md
Last active April 11, 2018 10:16
Abstracting APIs

Abstracting APIs

Assume you're developing an XKCD comic browser on Android. The API offers two endpoints:

There are numerous ways to access the above endpoints: either with libraries such as Retrofit, Volley, Ion, or manually, using e.g. HttpURLConnectionand AsyncTasks, Services, Loaders or other building blocks offered by the SDK.

With constant improvements, best practices and new libraries, it's good to not be tied to a particular implementation

@tslamic
tslamic / DeviceNames.bytecode
Created August 22, 2015 12:33
Potential implementations for AndroidDeviceNames. See http://tslamic.github.io/creating-android-device-names/ for more info.
Compiled from "DeviceNames.java"
public final class io.github.tslamic.adntest.DeviceNames {
public static java.lang.String getCurrentDeviceName(java.lang.String);
Code:
0: getstatic #1 // Field android/os/Build.MODEL:Ljava/lang/String;
3: aload_0
4: invokestatic #2 // Method getDeviceName:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
7: areturn
public static java.lang.String getDeviceName(java.lang.String, java.lang.String);