Skip to content

Instantly share code, notes, and snippets.

View laminr's full-sized avatar

Thibault de Lambilly laminr

View GitHub Profile
@laminr
laminr / IgnoreAccentsArrayAdapter.java
Created May 28, 2018 18:31 — forked from EsteveAguilera/IgnoreAccentsArrayAdapter.java
ArrayAdapter to use with Android AutoCompleteTextView or MultiAutoCompleteTextView that will ignore the accents for the completion suggestions. Based on the code from http://stackoverflow.com/questions/4869392/diacritics-international-characters-in-autocompletetextview
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
@laminr
laminr / README.md
Created May 24, 2018 08:23 — forked from lopspower/README.md
All Android Directory Path

All Android Directory Path

Twitter

1) System directories

⚠️ We can't write to these folers

Method Result
/*
* Copyright (C) 2006 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
@laminr
laminr / docker_kill.sh
Created February 11, 2018 19:14 — forked from evanscottgray/docker_kill.sh
kill all docker containers at once...
docker ps | awk {' print $1 '} | tail -n+2 > tmp.txt; for line in $(cat tmp.txt); do docker kill $line; done; rm tmp.txt
@laminr
laminr / distance.sql
Created January 18, 2018 09:34 — forked from aramonc/distance.sql
MySQL function to calculate the distance between two coordinates using the Haversine formula. Leaving it here for future reference.
DELIMITER $$
CREATE FUNCTION `haversine` (lat1 DECIMAL(8,6), lng1 DECIMAL(8,6), lat2 DECIMAL(8,6), lng2 DECIMAL(8,6)) RETURNS DECIMAL(8,6)
BEGIN
DECLARE R INT;
DECLARE dLat DECIMAL(30,15);
DECLARE dLng DECIMAL(30,15);
DECLARE a1 DECIMAL(30,15);
DECLARE a2 DECIMAL(30,15);
DECLARE a DECIMAL(30,15);
DECLARE c DECIMAL(30,15);
private fun updateActionBar() {
Log.v(TAG, "Back stack size: " + supportFragmentManager.backStackEntryCount)
when(supportFragmentManager.backStackEntryCount) {
0 -> {
settings.visibility = VISIBLE
back.visibility = GONE
}
else -> {
settings.visibility = GONE
back.visibility = VISIBLE
@Converter(autoApply = true)
public class LocalDateAttributeConverter implements AttributeConverter<LocalDate, Date> {
@Override
public Date convertToDatabaseColumn(LocalDate locDate) {
return (locDate == null ? null : Date.valueOf(locDate));
}
@Override
public LocalDate convertToEntityAttribute(Date sqlDate) {
@laminr
laminr / DisplayHandler.kt
Last active November 13, 2017 08:19
Help to flip visibility for a list of Views
import android.view.View
/**
* Created by Thibault de Lambilly on 11/11/2017.
* Help to flip visibility for a list of Views
*/
class DisplayHandler {
enum class RuleType { FOLLOW, MIRROR }
data class ViewProperty(val view: View, val rule: RuleType = RuleType.FOLLOW)
@laminr
laminr / README.md
Created October 21, 2017 14:12 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@laminr
laminr / ifNotNull.kt
Last active November 11, 2017 11:31 — forked from davidvavra/TwoNullChecksCode.kt
Functions that check several object for null state, then return their non null version
/**
* Created by Thibault de Lambilly on 11/11/2017.
* Functions that check several object for null state, then return their non null version
*/
fun <T1, T2> ifNotNull(value1: T1?, value2: T2?, bothNotNull: (T1, T2) -> (Unit)) {
if (value1 != null && value2 != null) {
bothNotNull(value1, value2)
}
}