Skip to content

Instantly share code, notes, and snippets.

Avatar
☄️

Mickaël Allonneau flawyte

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

Given this function :

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

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

@flawyte
flawyte / README.md
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
flawyte / Device.java
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".
View Device.java
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
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
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) {
return Object.prototype.toString.call(p)
.match(/\[object (.*)\]/)[1];
};