Skip to content

Instantly share code, notes, and snippets.

Prateek Srivastava f2prateek

Block or report user

Report or block f2prateek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am f2prateek on github.
  • I am f2prateek (https://keybase.io/f2prateek) on keybase.
  • I have a public key whose fingerprint is 39D2 2AF2 9FEA AE17 31BD 0B29 6D58 B458 1842 C429

To claim this, I am signing this object:

View InMemorySharedPreferences.java
package com.f2prateek.rx.preferences;
import android.content.SharedPreferences;
import android.support.annotation.Nullable;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@f2prateek
f2prateek / check.go
Created Sep 27, 2015
Script that checks which component dependencies need to be updated.
View check.go
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"strings"
"sync"
@f2prateek
f2prateek / dex.java
Created Jan 20, 2015
Print all classes in a DexFile
View dex.java
try {
File dexFileOutputDir = context.getDir("dexFileOutput" + fileKey, Context.MODE_PRIVATE);
File dexFileOutputFile = new File(dexFileOutputDir, "dex");
DexFile dx =
DexFile.loadDex(jarFile.getAbsolutePath(), dexFileOutputFile.getAbsolutePath(), 0);
// Print all classes in the DexFile
for (Enumeration<String> classNames = dx.entries(); classNames.hasMoreElements(); ) {
String className = classNames.nextElement();
System.out.println("class: " + className);
}
@f2prateek
f2prateek / zip.java
Created Jan 20, 2015
Read classes in a Zipfile
View zip.java
try {
ZipFile zipFile = new ZipFile(jarFile);
for (Enumeration<? extends ZipEntry> entries = zipFile.entries();
entries.hasMoreElements(); ) {
String name = entries.nextElement().getName();
System.out.println("entry: " + name);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
View AndroidCI.md

#Android and CI and Gradle (A How-To)

There are tech stacks in this world that make it dead simple to integrate a CI build system.
The Android platform is not one of them.

Although Gradle is getting better, it's still a bit non-deterministic, and some of the fixes you'll need will start to feel more like black magic than any sort of programming.

But fear not! It can be done!

Before we embark on our journey, you'll need a few things to run locally:

@f2prateek
f2prateek / Readme.md
Last active Aug 29, 2015
A Queue implementation for Tape.
View Readme.md

A java.util.Queue implementation for Tape (does not support iteration).

Swapping implementations is easy!

@Module
class ProductionModule {
  @Provides @Named("payloads") Queue<Payload> providePayloadQueue(File queueFile, Converter<Payload> payloadConverter) {
    return new Tape<Payload>(queueFile, payloadConverter);
  }
@f2prateek
f2prateek / Converter.java
Last active Aug 29, 2015
A mini gson implementation.
View Converter.java
import java.io.InputStream;
import java.io.OutputStream;
public interface Converter {
public <T> T fromJson(InputStream in, Class<T> clazz) throws ConversionException;
public <T> void toJson(OutputStream os, T object) throws ConversionException;
public class ConversionException extends Exception {
public ConversionException(Throwable throwable) {
View gist:3fc33c28125cf2824b58
// This is an aar, we'll ignore resources, and extract clases.jar
def outputDirName = "${buildDir}\\unpacked\\dist\\extracted"
System.out.println('Start')
print(file(outputDirName).list())
def extract = project.tasks.create "jarExtract${it.name.capitalize()}", Copy
extract.from it
extract.into outputDirName
extract.execute()
@f2prateek
f2prateek / HttpRequestAdapter.java
Created Jun 4, 2014
Signing Requests with Retrofit and SignPost
View HttpRequestAdapter.java
package com.f2prateek.five00px.data.api.auth;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import oauth.signpost.http.HttpRequest;
import retrofit.client.Header;
import retrofit.client.Request;
You can’t perform that action at this time.