Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tbruyelle's full-sized avatar

Thomas Bruyelle tbruyelle

View GitHub Profile
func tmpl(w io.Writer, text string, data interface{}) {
t := template.New("top")
t.Funcs(template.FuncMap{
"trim": strings.TrimSpace,
// deref allows to use pointer in templates
"deref": func(data interface{}) string {
if reflect.ValueOf(data).IsNil() {
return ""
}
switch vv := data.(type) {
public static Map<String, String> getHashMapResource(Context c, int hashMapResId) {
Map<String, String> map = null;
XmlResourceParser parser = c.getResources().getXml(hashMapResId);
String key = null, value = null;
try {
int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
/*
* Copyright (C) 2014 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
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:layout_marginLeft="72dp"
android:background="#9e9e9e"
android:src="@android:drawable/divider_horizontal_dim_dark"
/>
@tbruyelle
tbruyelle / gist:535816a7da15eab56c89
Last active August 29, 2015 14:24
list_section.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:paddingLeft="72dp"
android:paddingRight="16dp"
android:textColor="?android:attr/textColorSecondary"
public class Fetcher {
public Observable<String> fetch() {
return Observable.just("1","2","3").compose(composer());
// Compiler error: Incompatible type: required Observable<String>, found Observable<Object>
}
private <T> Observable.Transformer<T,T> composer() {
return new Observable.Transformer<T, T>() {
@Override
@tbruyelle
tbruyelle / RadarView.java
Created September 9, 2014 12:55
RadarView
/*
* Copyright (C) 2008 Google Inc.
*
* 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
@tbruyelle
tbruyelle / OkHttpStack.java
Created August 7, 2014 08:09
Volley & OkHttp
package com.comalia.gesicamobile.manager.net;
import com.android.volley.toolbox.HurlStack;
import com.comalia.gesicamobile.manager.util.NukeSSLCerts;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.OkUrlFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
@tbruyelle
tbruyelle / SingleClickListener.java
Created July 31, 2014 09:56
SingleClickListener
package com.tweetping.util;
import android.os.SystemClock;
import android.view.View;
import android.widget.AdapterView;
public abstract class SingleClickListener
implements AdapterView.OnItemClickListener, View.OnClickListener {
private static final long MIN_CLICK_INTERVAL = 600;
package com.comalia.gesicamobile.manager.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import com.comalia.gesicamobile.manager.R;