Skip to content

Instantly share code, notes, and snippets.

View amadeu01's full-sized avatar
:octocat:
Working from Stockholm

Amadeu Cavalcante Filho amadeu01

:octocat:
Working from Stockholm
View GitHub Profile
@amadeu01
amadeu01 / MockPositionProvider.java
Last active August 4, 2017 18:46
Provide location from route.json
import android.content.Context;
import android.content.res.AssetManager;
import android.location.Location;
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
@amadeu01
amadeu01 / Playground.swift
Created August 6, 2017 20:28 — forked from naoty/Playground.swift
A playground to display a table view controller on a navigation controller
import PlaygroundSupport
import UIKit
struct Pokemon {
let id: UInt
let name: String
}
class PokedexViewController: UITableViewController {
let pokemons: [Pokemon] = [
public static void printAllIntentData(Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}
}
}
@amadeu01
amadeu01 / MessageColumns.java
Created October 17, 2017 12:19
Helper for SMS retrieve messages
import android.annotation.SuppressLint;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.provider.Telephony;
import android.util.Log;
public class MessageColumns {
public static final int COLUMN_MSG_TYPE = 0;
public static final int COLUMN_ID = 1;
@amadeu01
amadeu01 / MessageColumns.java
Created October 17, 2017 12:19
Helper for SMS retrieve messages
import android.annotation.SuppressLint;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.provider.Telephony;
import android.util.Log;
public class MessageColumns {
public static final int COLUMN_MSG_TYPE = 0;
public static final int COLUMN_ID = 1;
@amadeu01
amadeu01 / MessageColumns.java
Created October 17, 2017 12:19
Helper for SMS retrieve messages
import android.annotation.SuppressLint;
import android.database.Cursor;
import android.provider.BaseColumns;
import android.provider.Telephony;
import android.util.Log;
public class MessageColumns {
public static final int COLUMN_MSG_TYPE = 0;
public static final int COLUMN_ID = 1;
import java.io.IOException;
import br.com.agileprocess.agileroutes.BuildConfig;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
public class UserAgentInterceptor implements Interceptor {
public UserAgentInterceptor() {}
@amadeu01
amadeu01 / SMSMMSService.java
Created October 23, 2017 17:03
Service to send SMS
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.klinker.android.send_message.ApnUtils;
import com.klinker.android.send_message.Message;
@amadeu01
amadeu01 / docker-inspect.sh
Created November 8, 2017 12:49
Magic bash
function dc_trace_cmd() {
local parent=`docker inspect -f '{{ .Parent }}' $1` 2>/dev/null
declare -i level=$2
echo ${level}: `docker inspect -f '{{ .ContainerConfig.Cmd }}' $1 2>/dev/null`
level=level+1
if [ "${parent}" != "" ]; then
echo ${level}: $parent
dc_trace_cmd $parent $level
fi
}
@amadeu01
amadeu01 / simple_test_django.py
Last active November 9, 2017 11:48
How to simple test views with authentication on django.
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
@login_required(login_url='/users/login')
def secure(request):
user = request.user
return render(request, 'secure.html', {'email': user.email})