Skip to content

Instantly share code, notes, and snippets.

🤓
🦀

Felipe Lima felipecsl

🤓
🦀
Block or report user

Report or block felipecsl

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
@felipecsl
felipecsl / ExceptionParser.java
Last active Jan 28, 2019
Helper class to parse error response body on Retrofit 2
View ExceptionParser.java
public static class ExceptionParser {
private final ResponseBody body;
private final String bodyString;
private final Converter.Factory converterFactory;
public ExceptionParser(Response response, Converter.Factory converterFactory) {
this.converterFactory = converterFactory;
this.body = cloneResponseBody(response.errorBody());
this.bodyString = getBodyAsString(body);
}
View cristiano_ronaldo.json
{
"page":1,
"totalPages":1,
"totalResults":1,
"type":"FUTPlayerItemList",
"count":1,
"items":[
{
"commonName":"Cristiano Ronaldo",
"firstName":"C. Ronaldo",
View gist:4dadf99531348534d2aa
private static List<File> findAllFiles(String baseDirectory) {
List<File> files = new LinkedList<File>();
List<File> directories = new LinkedList<File>();
directories.add(new File(baseDirectory));
while (!directories.isEmpty()) {
File [] subFiles = directories.remove(0).listFiles();
for (File f : subFiles) {
if (f.isDirectory()) {
View FormUrlEncodedRequest.java
package retrofit.labs;
import com.squareup.okhttp.RequestBody;
import java.util.Map;
public abstract class FormUrlEncodedRequest<T> extends Request<T> {
public FormUrlEncodedRequest(Listener<T> listener) {
super(listener);
@felipecsl
felipecsl / BundleBuilder.java
Last active Aug 29, 2015
Convenience classes for Fragment instantiation/setting arguments and chaining Bundle calls. MIT license
View BundleBuilder.java
import android.os.Bundle;
import android.os.Parcelable;
/**
* A Bundle that doesn't suck. Allows you to chain method calls as you'd expect.
*/
public class BundleBuilder {
private final Bundle bundle;
@felipecsl
felipecsl / gist:74da359d3db68031b638
Created Feb 13, 2015
Select long running queries from MySQL. Tweak the time to your desire
View gist:74da359d3db68031b638
SELECT * FROM information_schema.processlist WHERE info IS NOT NULL AND TIME > 1;
@felipecsl
felipecsl / gist:c6fa823f20f2087d762a
Created Feb 13, 2015
Fire up Android Intent from ADB (command line)
View gist:c6fa823f20f2087d762a
adb shell am start -a android.intent.action.VIEW -d “scheme://host/path?query=value"
View gist:18ceadcd45f957ab1ce8
### Keybase proof
I hereby claim:
* I am felipecsl on github.
* I am felipecsl (https://keybase.io/felipecsl) on keybase.
* I have a public key whose fingerprint is 4D6F 916F A81F 5861 1066 5FE5 E062 1CF8 F64A 2D1B
To claim this, I am signing this object:
@felipecsl
felipecsl / NoOverscrollSwipeRefreshLayout.java
Last active Jul 21, 2018
Modified Android SwipeRefreshLayout that does not move down the content view on swipe down (no overscroll)
View NoOverscrollSwipeRefreshLayout.java
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@felipecsl
felipecsl / incrementVersionCode
Created Dec 10, 2013
Increments the android versionCode automatically on each debug or release build
View incrementVersionCode
task('increaseVersionCode') << {
def manifestFile = file("src/main/AndroidManifest.xml")
def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
def matcher = pattern.matcher((CharSequence)manifestFile.getText())
matcher.find()
def versionCode = Integer.parseInt(matcher.group(1))
manifestFile.write(matcher.replaceAll("versionCode=\"" + ++versionCode + "\""))
}
assembleDebug.dependsOn 'increaseVersionCode'
You can’t perform that action at this time.