Skip to content

Instantly share code, notes, and snippets.

@sibelius
sibelius / woovi_challenge.md
Last active May 2, 2024 03:03
Woovi Challenge
@chrisdlangton
chrisdlangton / hmac_decorator.py
Last active May 2, 2024 03:03
Time-based HMAC signature SHA256, SHA512, SHA3-256, SHA3-384, SHA3-512, and BLAKE2 for Python Flask with Javascript Forge.js and Bash/OpenSSL/Curl clients
import hashlib
import hmac
from base64 import b64encode
from functools import wraps
from datetime import datetime, timedelta
from flask import request, abort
from flask_login import login_user
from models import User, ApiKey
def require_hmac(not_before_seconds: int = 3, expire_after_seconds: int = 3):
@ajumalp
ajumalp / Install Mosquitto MQTT on Synology NAS Server.txt
Last active May 2, 2024 03:00
Install Mosquitto MQTT on Synology NAS Server
From https://synocommunity.com add http://packages.synocommunity.com to your NAS package sources.
For that, go to NAS->Package Cnter->Click Settings->Package Sources tab.
Then from the community, you can see Mosquitto. Install it.
After installing, please stop the Mosquitto service before updating configuration. You can start service after changes.
Enable Admin login for Synology
Enable SSH in NAS
Download putty and connect to NAS Server
Login using admin
Change to root user [sudo -i, {use admin password}]
Find mosquitto.conf file [find / -name mosquitto.conf]
// <https://dev.to/jorik/country-code-to-flag-emoji-a21>
function getFlagEmoji(countryCode) {
const codePoints = countryCode
.toUpperCase()
.split('')
.map(char => 127397 + char.charCodeAt());
return String.fromCodePoint(...codePoints);
}
const array = [1, 2, 3, 4, 5];
array.groupBy((num, index, array) => {
return num % 2 === 0 ? 'even': 'odd';
});
// => { odd: [1, 3, 5], even: [2, 4] }>
const odd = { odd: true };
const even = { even: true };

You can clone the wiki of your github project via ssh:

git clone git@github.com:YOUR_USERNAME/YOUR_REPOSITORY.wiki.git
@nilsandrey
nilsandrey / qsParam.js
Created October 26, 2021 06:02
Return the value of an expected query string parameter. Return `null` if not present.
export function qsParam(name) {
return new URLSearchParams(document.location.search).get(name);
}
@nilsandrey
nilsandrey / node-static-serve.js
Last active May 2, 2024 02:59
NodeJS based directory browsing and file serve without dependencies
// NodeJS based directory browsing and file serve without dependencies
// Joining code from <https://stackoverflow.com/questions/16333790/node-js-quick-file-server-static-files-over-http>
var fs = require("fs"),
http = require("http");
http
.createServer(function (req, res) {
// Website you wish to allow to connect
res.setHeader("Access-Control-Allow-Origin", "*");
@fatum12
fatum12 / ttc2ttf.pe
Last active May 2, 2024 02:59
Unpack .ttc and .dfont to .ttf using FontForge
#!/usr/local/bin/fontforge
# Usage: fontforge -script ttc2ttf.pe /path/to/font.ttc
fonts = FontsInFile($1)
n = SizeOf(fonts)
i = 0
while (i < n)
Open($1 + "(" + fonts[i] + ")", 1)
index = ToString(i + 1)