Skip to content

Instantly share code, notes, and snippets.

@rogerhu
rogerhu / google-image-search-walkthrough
Last active September 11, 2023 02:47
Google Image Search
# Google Image Search
- SETUP see 0a_recording.txt BEFORE RECORDING
Keys: Cmd-Shift-O and Cmd-Shift-F
Tabs
- Grid image homework
- Project slides for Grid Image Search
- Guides
@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"
@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;
@rogerhu
rogerhu / Contact.java
Last active June 9, 2022 23:32
Endless scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {
// 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;
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 / 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) {
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 / 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');