Skip to content

Instantly share code, notes, and snippets.

View JeremieLitzler's full-sized avatar

Jérémie LITZLER JeremieLitzler

View GitHub Profile
@JeremieLitzler
JeremieLitzler / FileMagicNumberHelper.cs
Created December 8, 2023 10:47
Make sure the file is what it seems...
namespace Awesome.Csharp.Utilities.EveryoneNeeds
{
public static class FileMagicNumberHelper
{
public static bool CheckUploadedFileMagicNumber(byte[] file)
{
//No file
if (file == null) return false;
//File contains less than 2 bytes
if (file.Count() < 2) return false;
@JeremieLitzler
JeremieLitzler / convert-csv-to-json.js
Created September 7, 2022 12:37
Convert a CSV to JSON
//Inspired from https://stackoverflow.com/a/59017439
function csvToJSON(csv, seperator) {
var lines = csv.split("\n");
var result = [];
var headers;
headers = lines[0].split(seperator);
for (var i = 1; i < lines.length; i++) {
var obj = {};
@JeremieLitzler
JeremieLitzler / download-file-no-async-await.js
Last active July 26, 2022 14:18
How do you wait in vanilla in a loop?
let waitTime = 1000
const waitStep = 100;
htmlFiles.forEach((htmlFile) => {
delay(wait).then(() => {
console.log("downloading: " + htmlFile.filename);
download(htmlFile.content, htmlFile.filename, "text/html")
console.log("downloaded: " + htmlFile.filename);
});
wait += waitStep;
});
@JeremieLitzler
JeremieLitzler / mwn-nd-s1-checklist.md
Created April 4, 2018 08:30
MWS ND 2018 - Stage 1 checklist

Restaurant Reviews: Stage 1

Responsive Design

  • Is the site UI compatible with a range of display sizes?
    • All content is responsive and displays on a range of display sizes.
    • Content should make use of available screen real estate and should display correctly at all screen sizes.
    • An image's associated title and text renders next to the image in all viewport sizes.
  • Are images responsive?
  • Images in the site are sized appropriate to the viewport and do not crowd or overlap other elements in the browser, regardless of viewport size.
@JeremieLitzler
JeremieLitzler / recursive-path-array.js
Created April 4, 2018 04:02
Recursive path array
const locations = {
usa: {
alaska: ["Fairbanks", "Wasilla"],
california: ["San Fransisco", "Los Angeles"],
nevada: ["Las Vegas"],
massachusetts: ["Charlton"],
washington: ["Seattle"],
}
}
@JeremieLitzler
JeremieLitzler / app.js
Created March 23, 2018 13:58
MWS ND 2018 - Service worker registration
let appAlias = "";
if (location.hostname === "localhost") {
appAlias = "/mws-restaurant-stage-1";
}
function registerServiceWorker() {
if (!navigator.serviceWorker) {
console.log("ServiceWorker is not compatible with this browser...");
return;
}
@JeremieLitzler
JeremieLitzler / sw.js
Created March 23, 2018 13:50
Service worker MWS ND 2018
let appAlias = "";
if (location.hostname === "localhost") {
appAlias = "/mws-restaurant-stage-1";
}
const staticCacheName = "rreviews-data-v2";
const contentImgsCache = "rreviews-imgs";
const allCaches = [staticCacheName, contentImgsCache];
self.addEventListener("install", function(event) {
event.waitUntil(