Skip to content

Instantly share code, notes, and snippets.

View lzyzsd's full-sized avatar
:octocat:

Young for you lzyzsd

:octocat:
  • Open Source
  • singapore
View GitHub Profile
public class CircularProgressDrawable extends Drawable
implements Animatable {
private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator();
private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator();
private static final int ANGLE_ANIMATOR_DURATION = 2000;
private static final int SWEEP_ANIMATOR_DURATION = 600;
private static final int MIN_SWEEP_ANGLE = 30;
private final RectF fBounds = new RectF();

#[Tutorial] Android unit testing with Gradle, Robolectric, Dagger and Mockito Not long ago I faced the problem of setting up Gradle, Robolectric and Dagger for unit testing my app. And after tinkering a bit, I managed to make them all work together. In this tutorial I assume that you know how to work with Gradle, Robolectric, Dagger and Mockito separately.

I'm just going to show that they can work together pretty neatly, and how can they make Android testing a lot easier ##Wiring Robolectric and Gradle First of all, you're going to need a fully set up Android project ready to be built with Gradle. And I'm assuming that you're using default project layout (e.g. your java sources are located in $projectDir/src/main/java/)

For the next step we need to install a [Gradle Android test plugin][1] to a local maven repository:

#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
import java.lang.reflect.Type;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
public class MapData {
private int id;
private String city;
private String street;
/**
*
* Here's a thing that will look through all the text nodes of a document, and
* upon encountering an emoji codepoint, will replace it with an image.
* For now, those images are pulled from GitHub, which isn't very nice, so I
* need to find a more suitable host.
*
* Much of this code was gleaned from staring at the minified GitHub JS.
*
* Copyright (c) 2013 Mark Wunsch. Licensed under the MIT License.
@lzyzsd
lzyzsd / client.js
Created December 4, 2013 01:30 — forked from aelaguiz/client.js
var ChatRoom = function ChatRoom(chatList, inputArea, list) {
var _chatList = chatList,
_inputText = inputArea,
_userList = list,
_nickList = [];
/*
* Handle three events from the communications layer
*/
this.expose = {
@lzyzsd
lzyzsd / .bowerrc
Created November 18, 2013 01:41 — forked from facultymatt/.bowerrc
{
"directory": "components"
}
authRouteProvider.$inject = ['$routeProvider'];
function authRouteProvider ($routeProvider) {
/**
* Creates a controller bound to the route, or wraps the controller in param
* so the authentication check is run before the original controller is executed
* @param currentController
* @return {Function} The wrapper controller
*/
function redirectCtrlFactory (currentController) {
_ctrl.$inject = ['currentUser__', 'userRole__', '$location'];
@lzyzsd
lzyzsd / gist:7020717
Last active December 25, 2015 18:29 — forked from seansullivan/gist:4507044
allowCrossDomain middleware for expressjs or compundjs
#CORS middleware
allowCrossDomain = (req, res, next) ->
res.header 'Access-Control-Allow-Origin', '*'
res.header 'Access-Control-Allow-Methods', 'OPTIONS,GET,PUT,POST,DELETE'
res.header 'Access-Control-Allow-Headers', 'Content-Type, X-Requested-With'
next()
# Cut off OPTIONS requests and just send true as response
handleOptionsMethod = (req, res, next) ->
return res.send(200) if req.method == 'OPTIONS'
Highcharts.Chart.prototype.callbacks.push(function(chart) {
var hasTouch = hasTouch = document.documentElement.ontouchstart !== undefined,
mouseTracker = chart.tracker,
container = chart.container,
mouseMove;
mouseMove = function (e) {
// let the system handle multitouch operations like two finger scroll
// and pinching
if (e && e.touches && e.touches.length > 1) {