Skip to content

Instantly share code, notes, and snippets.

View laminr's full-sized avatar

Thibault de Lambilly laminr

View GitHub Profile
@laminr
laminr / gist:571b4cc65dd734d4345209a3dca3cd4c
Created June 18, 2022 13:15 — forked from donaldallen/gist:9557256
Handle Daylight Savings Time (DST) in Javascript.
var today = new Date();
Date.prototype.stdTimezoneOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1);
var jul = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
}
Date.prototype.dst = function() {
return this.getTimezoneOffset() < this.stdTimezoneOffset();
@laminr
laminr / purgeAndroid.txt
Created July 3, 2020 17:39 — forked from tahmidsadik/purgeAndroid.txt
How to completely remove Android Studio from Mac OS X
How to Completely Remove Android Studio
Execute these commands from the terminal
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
@laminr
laminr / mysql-docker.sh
Created April 29, 2019 12:36 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@laminr
laminr / CallReceiver.kt
Last active February 6, 2019 13:48 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.foo.bar.receiver
import android.content.Context
import timber.log.Timber
import java.util.*
class CallReceiver : PhonecallReceiver() {
override fun onIncomingCallReceived(ctx: Context, number: String, start: Date) {
Timber.d("onIncomingCallReceived: $number")
@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
@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);
@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) {