Skip to content

Instantly share code, notes, and snippets.

View vguillou's full-sized avatar

Vincent Guillou vguillou

  • Padoa
  • Planet Earth
View GitHub Profile
@vguillou
vguillou / estimate.js
Last active September 28, 2019 13:10
Pretty print to console the estimation of storage available to your site, via the Storage API
function bytesToString(bytesCount) {
const kCoef = Math.pow(2, 10);
const mCoef = Math.pow(kCoef, 2);
const gCoef = Math.pow(kCoef, 3);
if (bytesCount < kCoef) return `${bytesCount}b`;
if (bytesCount < mCoef) return `${(bytesCount / kCoef).toFixed(2)}kb`;
if (bytesCount < gCoef) return `${(bytesCount / mCoef).toFixed(2)}mb`;
return `${(bytesCount / gCoef).toFixed(2)}gb`;
}
@vguillou
vguillou / cloudSettings
Last active February 19, 2020 23:08
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-19T23:07:51.382Z","extensionVersion":"v3.4.3"}
@vguillou
vguillou / _Stay_standalone.md
Last active February 24, 2017 21:10 — forked from irae/_Stay_standalone.md
Stay Standalone: Prevent links in standalone web apps opening Mobile Safari

#Stay Standalone

A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally. Also redirects to the webapp's home page if the start URL of said webapp isn't the home screen (configurable, simply replace /index.html by your home screen path in compressed.js).

@vguillou
vguillou / EverlastingService.java
Last active October 25, 2016 09:57
A persistent and resilient Android service that runs on a background thread
package org.vguillou.android.test.service;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;