Skip to content

Instantly share code, notes, and snippets.

View luctrudeau's full-sized avatar

Luc Trudeau luctrudeau

View GitHub Profile
rgb = imread(fileName);
[h, w, ~] = size(rgb);
cx = round(w / 2);
cy = round(h / 2);
imshow(rgb);
e = imellipse(gca, [cx - (cy), 0, h h]);
wait(e);
Testing comment
@luctrudeau
luctrudeau / gist:dd20e7b35efe60efa608
Last active August 29, 2015 14:23
Android Base64 Example
byte[] octets = "ETS".getBytes("UTF-8");
String base64 = Base64.encodeToString(octets, Base64.URL_SAFE);
byte[] octets = Base64.decode(base64, Base64.URL_SAFE);
String text = new String(octets, "UTF-8");
AsyncTask<URL, String, String> httpTask = new AsyncTask<URL, String, String>() {
@Override
protected String doInBackground(URL... urls) {
HttpURLConnection urlConnection = null;
StringBuilder sb = new StringBuilder();
try {
urlConnection = (HttpURLConnection) urls[0].openConnection();
try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()))) {
for (String line = in.readLine(); line != null; line = in.readLine()) {
sb.append(line);
@luctrudeau
luctrudeau / longpolling.uml
Last active August 29, 2015 14:23
Long Polling
@startuml
hide footbox
Client -> Server: HTTP Get << Long Lived>>
activate Client
activate Server
Server -> Server: serve()
activate Server

HTTP Long Polling

@luctrudeau
luctrudeau / MotionEstimation
Created July 8, 2015 16:41
Motion Estimation illustrated with Tikz
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage[caption=false]{subfig}
\usepackage[noabbrev]{cleveref}
\usepackage{schemabloc}
\usepackage{amsmath}
\usepackage{amssymb}
@luctrudeau
luctrudeau / PersistenceRecipe.java
Created July 14, 2015 22:48
Android Object Persistence Recipe
SharedPreferences settings = getSharedPreferences("ETSPref", 0);
List<String> ets = Arrays.asList("I", "Love", "ETS");
// Save Object
SharedPreferences.Editor editor = settings.edit();
editor.putString("ILoveETS", new Gson().toJson(ets));
editor.commit();
// Load Object
Lock lock = ...;
if (lock.tryLock()) {
try {
// manipulate protected state
} finally {
lock.unlock();
}
} else {
// perform alternative actions
}
@startuml
node {
interface "OSGI" as OSGI1
interface "OSGI" as OSGI2
interface "OSGI" as OSGI3
[Service 4 (service composé)] -down-> OSGI1
[Service 3\nGUI] -up- OSGI3
[Service 2\nSGR] -up- OSGI2
[Service 1\nSGS] -up- OSGI1