Skip to content

Instantly share code, notes, and snippets.

@rogerhu
rogerhu / stream_rtmp.sh
Created June 2, 2023 06:33
ffmpeg streaming from m3u8 to rtmps://
ffmpeg \
-i $1 \
-preset veryfast \
-vcodec libx264 \
-ar 44100 \
-f flv \
"$2"
The OAuth callback succeeded, but you are possibly using Android 7.0+ and Twitter's redirect may not be working correctly.
Switch back to your Android app and try to login again!
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Contact {
private int mId;
@rogerhu
rogerhu / PushTest.java
Last active October 10, 2017 09:59
Push Testing
// See https://github.com/rogerhu/parse-server-push-marker-example/blob/master/cloud/main.js#L43-L66
// for corresponding server code.
public class PushTest {
public static void sendPushTest() {
JSONObject payload = new JSONObject();
try {
payload.put("sender", ParseInstallation.getCurrentInstallation().getInstallationId());
} catch (JSONException e) {
@rogerhu
rogerhu / cloud.js
Created November 4, 2016 05:09
Parse Cloud Lab example
// See http://parseplatform.github.io/docs/js/guide/
// https://parseplatform.github.io/docs/js/guide/#query-constraints
Parse.Cloud.define('pushToChannel', function(request, response) {
var params = request.params;
var channel = params.channel;
if (!channel) {
response.error('must provide a channel');
// Inspired from https://gist.github.com/adrianbk/c4982e5ebacc6b6ed902
apply plugin: 'maven-publish'
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getOutputDir() {
if (isReleaseBuild()) {
import android.support.v7.widget.RecyclerView;
public class RecyclerViewSwipeListener extends RecyclerView.OnFlingListener {
private static final int SWIPE_VELOCITY_THRESHOLD = 2000;
boolean mIsScrollingVertically;
// change swipe listener depending on whether we are scanning items horizontally or vertically
RecyclerViewSwipeListener(boolean vertical) {
@rogerhu
rogerhu / MultimediaDeserializer.java
Created February 12, 2016 05:58
MultimEdia deserializer
package codepath.com.nytimesfun;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import android.text.TextUtils;
@rogerhu
rogerhu / EndlessRecyclerViewScrollListener.java
Last active October 6, 2022 04:42
Endless RecyclerView scrolling for different layout managers
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load.
private boolean loading = true;
// requires StringUtils -> better way?
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.net.CookieManager;
import java.net.CookiePolicy;
import java.net.CookieStore;
import java.net.URI;
import java.util.Arrays;
import java.util.HashMap;