Skip to content

Instantly share code, notes, and snippets.

View quantumsheep's full-sized avatar
🐑
S H E E P

Nathanael Demacon quantumsheep

🐑
S H E E P
View GitHub Profile
@quantumsheep
quantumsheep / walk.js
Created October 15, 2018 21:50 — forked from kethinov/walksync.js
List all files in a directory in Node.js recursively in a synchronous fashion
// List all files in a directory in Node.js recursively in an asynchronous fashion
const fs = require('fs').promises;
const path = require('path');
const walk = async (dir, filelist = []) => {
const files = await fs.readdir(dir);
for (file of files) {
const filepath = path.join(dir, file);
const stat = await fs.stat(filepath);
@quantumsheep
quantumsheep / app.js
Last active November 23, 2019 22:59
Summernote - OnImageUpload: Place image in editor if size is under 1Mo
$('#summernote').summernote({
callbacks: {
onImageUpload: function(image) {
if((image[0].size/1024/1024) > 1) {
alert("Merci de déposer une image inférieure à 1 Mo, sinon uploadez-là sur un site d'hébergement d'image ou sur PETERPAN et utilisez la fonction image.");
return false;
} else {
var file = image[0];
var reader = new FileReader();
reader.onloadend = function() {