This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let add = (tag, url) => new Promise( (resolve) => { | |
let el = document.createElement(tag); | |
if (tag === 'link') { | |
el.rel = 'stylesheet'; | |
el.href = url; | |
} | |
else if (tag === 'script') { | |
el.src = url; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Licence ISC | |
// global | |
let inited = !!(window as any).inview_scroll_targets; | |
let targets:[{el:HTMLElement, value:any}] = (window as any).inview_scroll_targets = (window as any).inview_scroll_targets || []; | |
function isElementOutViewport(el) { | |
let rect = el.getBoundingClientRect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Access CouchDB to get and update a security object using fetch | |
(does it directly, no pouchdb or alike needed. PouchDB CAN get a _security object but not set it). | |
Usage: | |
let con = 'http://admin:adminpw@localhost:5984/user-numberone'; | |
let secDoc = await getSecurity(con); | |
secDoc.members = ['user_to_add']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir app | |
cd app | |
npm init -y | |
npm i -D typescript | |
npm i ts-node | |
node_modules/.bin/tsc --init | |
touch index.ts | |
# package.json -> | |
# "start": "node_modules/.bin/ts-node index.ts", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Nabil Redmann, ISC License | |
// USE: import downloadBlob from 'downloadBlob.vue3.js'; app.use(downloadBlob); | |
export function downloadString(text:any, filename:string = 'unnamed.txt', mimeType:string = 'text/plain') { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"folders": [], | |
"settings": { | |
"extensions.ignoreRecommendations": false, | |
"prettier.arrowParens": "avoid", | |
"prettier.useTabs": true, | |
"prettier.requireConfig": true, | |
"html.format.indentInnerHtml": true, | |
"editor.formatOnSave": true, | |
"editor.formatOnType": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Part of https://github.com/chris-rock/node-crypto-examples | |
// Nodejs encryption of buffers | |
var crypto = require('crypto'), | |
algorithm = 'aes-256-ctr', | |
password = 'd6F3Efeq'; | |
var fs = require('fs'); | |
var zlib = require('zlib'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import formidable from 'formidable'; | |
router.post('/', async (ctx, next) => { | |
const form = formidable({ multiples: true, maxFileSize: 200 * 1024 * 1024 }); | |
let fields, files; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# has to be run in the folder where all files and sub-files should be changed (Win Powershell): | |
Get-ChildItem -force .\ * | ForEach-Object{$_.CreationTime = ("31 April 2022 16:01:43")} | |
Get-ChildItem -force .\ * | ForEach-Object{$_.LastWriteTime = ("31 April 2022 16:01:43")} | |
Get-ChildItem -force .\ * | ForEach-Object{$_.LastAccessTime = ("31 April 2022 16:01:43")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.write( | |
'<!-- include libraries(jQuery, bootstrap) -->' + | |
'<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">' + | |
'<script src="https://code.jquery.com/jquery-3.5.1.min.js"></scr'+'ipt>' + | |
'<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></scr'+'ipt>' + | |
'<!-- include summernote css/js -->' + | |
'<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">' + | |
'<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></scr'+'ipt>' + | |
'<script>$(function(){$("[data-summernote]").summernote();});</scr'+'ipt>' | |
); |