Skip to content

Instantly share code, notes, and snippets.

View vedhavyas's full-sized avatar
🐧

CrabGopher vedhavyas

🐧
  • Everywhere
View GitHub Profile
@vedhavyas
vedhavyas / .profile
Created July 12, 2017 13:04 — forked from bmhatfield/.profile
Automatic Git commit signing with GPG on OSX
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running.
# Add the following to your shell init to set up gpg-agent automatically for every shell
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then
source ~/.gnupg/.gpg-agent-info
export GPG_AGENT_INFO
else

Keybase proof

I hereby claim:

  • I am vedhavyas on github.
  • I am vedhavyas (https://keybase.io/vedhavyas) on keybase.
  • I have a public key whose fingerprint is F41E CDD3 DC96 7F1A AF2D 0308 BF62 2A66 FD4B 3589

To claim this, I am signing this object:

@vedhavyas
vedhavyas / PostExampleAndroid
Last active April 18, 2016 12:03
POST Request example in Android
//Add library by adding the following line in dependencies section in gradle file
compile 'com.squareup.okhttp3:okhttp:3.2.0'
//Making a Post request
OkHttpClient client = new OkHttpClient();
RequestBody body = new FormBody.Builder()
.add("name", "Name Here")
.add("email", "email here")
.add("purpose", "purpose here")
@vedhavyas
vedhavyas / FloatingService.java
Created April 10, 2016 12:07
Android Floating label
package com.instamojo.mink.services;
import android.animation.ValueAnimator;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.IBinder;
import android.view.Gravity;
@vedhavyas
vedhavyas / FetchUserPhoneNumber.java
Last active December 18, 2015 05:53
This code will fetch user phone number from contact card as well as accounts
private ArrayList<String> getOwnerPhone() {
ArrayList<String> numbers = new ArrayList<>();
getPhoneFromContacts(numbers);
getPhoneFromProfile(numbers);
return numbers;
}
private void getPhoneFromContacts(ArrayList<String> numbers) {
final AccountManager manager = AccountManager.get(this);
final Account[] accounts = manager.getAccountsByType("com.google");
@vedhavyas
vedhavyas / Attributes.java
Created November 28, 2014 08:44
Attribute combinations - A snippet to display the combinations of attributes
import java.util.Scanner;
public class Attributes{
public static void main(String [] args){
Scanner scanIN = new Scanner(System.in);
Scanner scanSTR = new Scanner(System.in);
String [] temp;
String str;
System.out.println("No. of attributes");
int numAtr = scanIN.nextInt();