Skip to content

Instantly share code, notes, and snippets.

@jingwings
jingwings / adbwifi.sh
Last active August 29, 2015 14:18 — forked from stormzhang/adbwifi.sh
#!/bin/bash
#Modify this with your IP range
MY_IP_RANGE="192\.168\.1"
#You usually wouldn't have to modify this
PORT_BASE=5555
#List the devices on the screen for your viewing pleasure
adb devices
@jingwings
jingwings / README.md
Created October 27, 2015 03:54 — forked from polbins/README.md
Android Response Caching using Retrofit 1.9 + OkHttp 2.2

Android REST Controller with Cache-Control

Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0

@jingwings
jingwings / retrofit-custom-error-handling.java
Created November 26, 2015 10:09 — forked from benvium/retrofit-custom-error-handling.java
Fairly simply Retrofit custom error handling example. Is set up so that you don't need to do much work in the 'failure' handler of a retrofit call to get the user-visible error message to show. Works on all endpoints. There's lots of exception handling as our server folks like to keep us on our toes by sending all kinds of random stuff..!
// on error the server sends JSON
/*
{ "error": { "data": { "message":"A thing went wrong" } } }
*/
// create model classes..
public class ErrorResponse {
Error error;
@jingwings
jingwings / Api.java
Created November 26, 2015 10:35 — forked from snadjafi/Api.java
android retrofit setup example
public final class Api {
//region Variables
private static final String API_HOST = Application.string(R.string.api_server);
private static final Object sLockObject = new Object();
private static Service sService = null;
static final int DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
//endregion
@jingwings
jingwings / curl.md
Created December 25, 2015 09:59 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@jingwings
jingwings / gitignore-android-studio-list
Created January 5, 2016 05:27 — forked from vtanathip/gitignore-android-studio-list
Git Ignore files list that should use in Android Studio Projects
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@jingwings
jingwings / iterm2-solarized.md
Created January 29, 2016 03:39 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

@jingwings
jingwings / fixXcode6OnElCapitan.sh
Created May 8, 2016 05:18 — forked from DaveWoodCom/fixXcode6OnElCapitan.sh
Script to fix Xcode 6.x so that it will run on El Capitan
#!/bin/bash
## Copyright (C) 2015 Cerebral Gardens http://www.cerebralgardens.com/
##
## Permission is hereby granted, free of charge, to any person obtaining a copy of this
## software and associated documentation files (the "Software"), to deal in the Software
## without restriction, including without limitation the rights to use, copy, modify,
## merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
## permit persons to whom the Software is furnished to do so, subject to the following
## conditions:
@jingwings
jingwings / OkHttpStack.java
Created May 12, 2016 01:17 — forked from bryanstern/OkHttpStack.java
An OkHttp backed HttpStack for Volley
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 Circle Internet Financial
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@jingwings
jingwings / WebViewClient
Created May 15, 2016 02:37 — forked from kibotu/WebViewClient
Android WebView: resource interception and replacement by local resource
mWebView.setWebViewClient(new WebViewClient() {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
if (url.contains("creditcard_cvc.jpg")) {
Log.v("WebView", "Replacing [" + url + "] with [R.raw.tmp_replacement]");
ContentResolver contentResolver = getActivity().getContentResolver();
return new WebResourceResponse(contentResolver.getType(Uri.parse(url)), "UTF-8", getResources().openRawResource(R.raw.tmp_replacement));
}
return super.shouldInterceptRequest(view, url);