Skip to content

Instantly share code, notes, and snippets.

View danielpassos's full-sized avatar

Daniel Passos danielpassos

View GitHub Profile
@selecsosi
selecsosi / gist:6705630
Created September 25, 2013 20:34
This is an asyncTask using the geocoder falling back to a HttpRequest using volley to find a location
/**
* Task to lookup the LatLng of an address
*/
public class SearchForLocationTask extends AsyncTask<String, Void, LatLng> {
private static final String TAG = SearchForLocationTask.class.getSimpleName();
Context mContext;
//Get static reference to requestQueue
RequestQueue mRequestQueue = MyApplication.getInstance().getRequestQueue();
@julianshen
julianshen / CircleTransform.java
Last active November 12, 2025 12:39
CircleTransform for Picasso
/*
* Copyright 2014 Julian Shen
*
* 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
@ficusk
ficusk / GsonRequest.java
Last active January 6, 2025 22:43
A Volley adapter for JSON requests that will be parsed into Java objects by Gson.
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;

AbstractPageRequestHandler.java

abstact class AbstractPageRequestHandler() {
    public List<Pair<String, String>>  getPagingHeaders(ReadFilter filter){
       List<Pair<String, String>> toReturn = new ArrayList<>();
       return toReturn;
    }
    
    public byte[] appendToBody(ReadFilter filter, byte[] body){
 return body;
public interface PagedResult<T> {
PagedResult<T> next();
PagedResult<T> prev();
PagedResult<T> withOffset(int offset);
PagedResult<T> withLimit(int limit);

Client Paging

This document describes the client side interfaces which a developer can use to Query and Page through data obtained from remote rest services. This document describes both how to interact with the Aerogear-Controller based paging as well how to extend the libraries and APIs to support most other restful services. It is currently Java centric, but this should be fixed up in the future.

At a high level, Paging and Querying is supported though the Pipe.readWithFilter(ReadFilter, Callback) method. A ReadFilter object will set the current page, number of results perPage, and a where property. The Pipe implementation will be responsible for processing a request along with any paging data and sending the appropriate headers, data, and query parameters to the server. Once the response has been received, the Pipe implementation will provide a List of objects to the supplied callback. If this call used paging, the List will be an instance of PagedList.

PagedList will be a List of results f

@alexrios
alexrios / EasyOrderBy.md
Last active December 11, 2015 02:18
Java "order by" made easy
//Smart use of enums
public enum DeviceComparator implements Comparator<Device> {
 
    ID {
        public int compare(Device o1, Device o2) {
            return Integer.valueOf(o1.getId()).compareTo(o2.getId());
        }},
    NAME {
        public int compare(Device o1, Device o2) {
@matzew
matzew / gist:4451467
Created January 4, 2013 10:11
Nice key/value init for the NSDictionary class...
NSDictionary *map = @{ @"key1": @"blah", @"key2": @"foo"};
class apt-get::update {
exec { "apt-get update":
command => "apt-get update"
}
}
@fnando
fnando / gist:4356057
Created December 21, 2012 21:49
Open screen session and connect to given ssh domain. Usage: $ ./prod example.org
#!/usr/bin/env bash
domain=$1
filename="/tmp/$(echo -n "$domain" | md5)"
read -r -d '' screenrc <<SCREENRC
startup_message off
shell /usr/local/bin/bash
autodetach on
defscrollback 10000