Skip to content

Instantly share code, notes, and snippets.

View hormesiel's full-sized avatar

Mickaël hormesiel

View GitHub Profile
@hormesiel
hormesiel / type.js
Created February 17, 2015 10:18
Returns a string representation of an object's exact type (e.g. "HTMLInputElement", "String", "Number", "Array"... or "Object" for plain objects).
function type(p) {
return Object.prototype.toString.call(p)
.match(/\[object (.*)\]/)[1];
};
@hormesiel
hormesiel / gist:a8ae2b3af67cedf1e507
Created March 17, 2015 14:07
Shows the SHA1 of the first commit made in a Git repository.
git rev-list --max-parents=0 HEAD
@hormesiel
hormesiel / Device.java
Last active May 29, 2024 11:47
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() {
@hormesiel
hormesiel / README.md
Last active April 19, 2020 14:04
GitHub Action to automatically rebuild and redeploy a website to ZEIT Now whenever content is edited in the CMS.
@hormesiel
hormesiel / README.md
Last active April 13, 2020 14:11
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.

@hormesiel
hormesiel / README.md
Last active May 24, 2020 11:31
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';
    else
        return 'else';
}