Skip to content

Instantly share code, notes, and snippets.

View gouravd's full-sized avatar

das_vicky gouravd

  • Cayfay
  • Hyderabad, India
View GitHub Profile

Keybase proof

I hereby claim:

  • I am gouravd on github.
  • I am gouravd (https://keybase.io/gouravd) on keybase.
  • I have a public key ASCj0sKbTBnLUaeZ3CgA2qARKPL9ChE9Jj4DYQPSxPA2cwo

To claim this, I am signing this object:

@gouravd
gouravd / YouTubeHelper.java
Created January 29, 2018 17:28 — forked from jvanderwee/YouTubeHelper.java
Extract video id from YouTube url in java
import com.google.inject.Singleton;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Singleton
public class YouTubeHelper {
final String youTubeUrlRegEx = "^(https?)?(://)?(www.)?(m.)?((youtube.com)|(youtu.be))/";
final String[] videoIdRegex = { "\\?vi?=([^&]*)","watch\\?.*v=([^&]*)", "(?:embed|vi?)/([^/?]*)", "^([A-Za-z0-9\\-]*)"};
@gouravd
gouravd / PatternEditableBuilder.java
Created November 22, 2017 16:04 — forked from nesquena/PatternEditableBuilder.java
PatternEditableBuilder - Easy way to create colored clickable spans within a TextView!
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.regex.Matcher;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import java.util.concurrent.CountDownLatch;
/**
* File Created by gouravd on 17/08/16.
@gouravd
gouravd / WifiDirectAutoAccept
Created May 12, 2016 13:38
WifiDirectAutoAccept
/*
* Copyright (c) 2012, AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@gouravd
gouravd / AACStream.java
Created April 26, 2016 07:10 — forked from sbaar/AACStream.java
libstreaming muxer
protected void encodeWithMediaCodec(){
...
mAudioRecord.startRecording();
mMediaCodec.start();
final MediaCodecInputStream inputStream = new MediaCodecInputStream(mMediaCodec);
if (mMuxer!=null) inputStream.setMuxer(mMuxer);
final ByteBuffer[] inputBuffers = mMediaCodec.getInputBuffers();
}
@gouravd
gouravd / 1_query_timestamp.js
Created April 15, 2016 16:01 — forked from katowulf/1_query_timestamp.js
Get only new items from Firebase
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP)
// pros: fast and done server-side (less bandwidth, faster response), simple
// cons: a few bytes on each record for the timestamp
var ref = new Firebase(...);
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) {
console.log('new record', snap.key());
});
@gouravd
gouravd / adb_over_wifi
Created February 11, 2016 05:27
adb over wifi
You need to connect your device to your computer via USB cable. Make sure USB debugging is working. You can check if it shows up when running adb devices.
Run adb tcpip 5555
Disconnect your device (remove the USB cable).
Go to the Settings -> About phone -> Status to view the IP address of your phone.
Run adb connect <IP address of your device>:5555
@gouravd
gouravd / EndlessRecyclerOnScrollListener.java
Created December 27, 2015 14:20 — forked from imran0101/EndlessRecyclerOnScrollListener.java
RecyclerView position helper to get first and last visible positions
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
@gouravd
gouravd / rotateYUVImage.java
Created September 26, 2015 20:40
Rotate YUVimage
public static byte[] rotateYUV420Degree90(byte[] data, int imageWidth, int imageHeight) {
byte[] yuv = new byte[imageWidth * imageHeight * 3 / 2];
// Rotate the Y luma
int i = 0;
for (int x = 0; x < imageWidth; x++) {
for (int y = imageHeight - 1; y >= 0; y--) {
yuv[i] = data[y * imageWidth + x];
i++;
}
}