Skip to content

Instantly share code, notes, and snippets.

View Sinequanonh's full-sized avatar
🏠
Working from home

leo Sinequanonh

🏠
Working from home
  • Paris
View GitHub Profile
@Sinequanonh
Sinequanonh / _readme.md
Created October 26, 2023 05:57 — forked from pongstr/_readme.md
HTTP/2 Recipe: Nginx + Node.js

Imgur

Recipe

Install homebrew/services, this will be helpful, you'll see later. :D

$ brew tap homebrew/services 
@Sinequanonh
Sinequanonh / is-url.js
Created November 22, 2022 23:11
is-url.js
/**
* Expose `isUrl`.
*/
module.exports = isUrl;
/**
* RegExps.
* A URL must match #1 and then at least one of #2/#3.
* Use two levels of REs to avoid REDOS.
@Sinequanonh
Sinequanonh / measurePromise.js
Created May 14, 2021 17:13
Measure promise time
const measurePromise = (p) => new Promise(async (resolve, reject) => {
const startHrTime = process.hrtime();
const res = await p;
const elapsedHrTime = process.hrtime(startHrTime);
const elapsedTimeInMs = Math.round(elapsedHrTime[0] * 1000 + elapsedHrTime[1] / 1e6);
console.log('elapsedTime', elapsedTimeInMs / 1000 + 's');
resolve(res);
});
module.exports = measurePromise;
# You should install youtube-dl locally and on the remote server
# To use: ./ytdl [video URL]
uuid="$(uuidgen).mp4";
ssh USER@IP_ADDRESS "
youtube-dl $1 --output $uuid
exit;
";
/*! Planetary.js 1.1.2 | (c) 2013 Michelle Tilley | Released under MIT License */
!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],function(o,i){return n.planetaryjs=t(o,i,n)}):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var i=null;o&&(i=o.planetaryjs);var e=[],r=function(t,o,i){n.timer(function(){if(t.stopped)return!0;t.context.clearRect(0,0,o.width,o.height);for(var n=0;n<i.onDraw.length;n++)i.onDraw[n]()})},l=function(n,t){for(var o=e.length-1;o>=0;o--)t.unshift(e[o]);for(0===t.length&&(c.plugins.earth&&n.loadPlugin(c.plugins.earth()),c.plugins.pings&&n.loadPlugin(c.plugins.pings())),o=0;o<t.length;o++)t[o](n)},a=function(n,t,o){if(o.onInit.length){var i=0,e=function(n){var t=o.onInit[i];t.length?t(function(){i++,n()}):(t(),i++,setTimeout(n,0))},l=function(){i>=o.onInit.length?r(n,t,o):e(l)};e(l)}else r(n,t,o)},u=function(n,t,o,i){n.canvas=t,n.context=t.getContext("2d"),n.stop
/*! Planetary.js 1.1.2 | (c) 2013 Michelle Tilley | Released under MIT License */
!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],function(o,i){return n.planetaryjs=t(o,i,n)}):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var i=null;o&&(i=o.planetaryjs);var e=[],r=function(t,o,i){n.timer(function(){if(t.stopped)return!0;t.context.clearRect(0,0,o.width,o.height);for(var n=0;n<i.onDraw.length;n++)i.onDraw[n]()})},l=function(n,t){for(var o=e.length-1;o>=0;o--)t.unshift(e[o]);for(0===t.length&&(c.plugins.earth&&n.loadPlugin(c.plugins.earth()),c.plugins.pings&&n.loadPlugin(c.plugins.pings())),o=0;o<t.length;o++)t[o](n)},a=function(n,t,o){if(o.onInit.length){var i=0,e=function(n){var t=o.onInit[i];t.length?t(function(){i++,n()}):(t(),i++,setTimeout(n,0))},l=function(){i>=o.onInit.length?r(n,t,o):e(l)};e(l)}else r(n,t,o)},u=function(n,t,o,i){n.canvas=t,n.context=t.getContext("2d"),n.stop
@Sinequanonh
Sinequanonh / telegram-bot.js
Last active October 25, 2023 06:09
Nodejs script to send Telegram push notifications
const TelegramBot = require('node-telegram-bot-api');
// replace the value below with the Telegram token you receive from @BotFather
const token = YOUR_TOKEN;
// read the doc from https://github.com/yagop/node-telegram-bot-api to know how to catch the chatId
const chatId = CHAT_ID;
const bot = new TelegramBot(token, { polling: false });
const telegrambot = (message, json) => {
@Sinequanonh
Sinequanonh / gist:4de9561bba99acb36f8d0b18988cc913
Created December 9, 2017 16:56
Add Swap Memory to a debian server
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
@Sinequanonh
Sinequanonh / shuffle.js
Created November 27, 2017 01:30 — forked from guilhermepontes/shuffle.js
Shuffle array element ES2015, ES6
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5)
shuffleArray([1, 2, 3]) //[3, 1, 2]