Skip to content

Instantly share code, notes, and snippets.


Mickaël Allonneau flawyte

View GitHub Profile
flawyte /
Last active May 24, 2020
How JavaScript handles inner `if` and outer `else` when there's no brackets

Given this function :

function testFn(a1, a2) {
    if (a1)
        if (a2)
            return 'a1 && a2';
        return 'else';
flawyte /
Last active Apr 13, 2020
Easiest XML-only solution I know to add a <ripple> to an <ImageView> (tested on API >= 21)

See the related Medium article for more info and a GIF showing the final result.

flawyte /
Last active Apr 19, 2020
GitHub Action to automatically rebuild and redeploy a website to ZEIT Now whenever content is edited in the CMS.
flawyte /
Last active Apr 25, 2021
How to get an Android device's serial number, visible to the user in "Settings > About phone/tablet/device > Status > Serial number".
import android.os.Build;
import java.lang.reflect.Method;
public class Device {
* @return The device's serial number, visible to the user in {@code Settings > About phone/tablet/device > Status
* > Serial number}, or {@code null} if the serial number couldn't be found
public static String getSerialNumber() {
flawyte / gist:a8ae2b3af67cedf1e507
Created Mar 17, 2015
Shows the SHA1 of the first commit made in a Git repository.
View gist:a8ae2b3af67cedf1e507
git rev-list --max-parents=0 HEAD
flawyte / type.js
Created Feb 17, 2015
Returns a string representation of an object's exact type (e.g. "HTMLInputElement", "String", "Number", "Array"... or "Object" for plain objects).
View type.js
function type(p) {
.match(/\[object (.*)\]/)[1];