Skip to content

Instantly share code, notes, and snippets.

@jfeilbach
jfeilbach / ubuntu_22.04_motd.md
Last active April 18, 2024 21:11
Make Ubuntu 22.04 less annoying. Remove ESM Ubuntu Advantage

Ubuntu 22.04 Annoyances

Here are a few collected ways I like to customize Ubuntu 22.04 servers. I used to love Ubuntu, but I hate auto updates and snaps. They also put ads and other usless ads diguised as "news" in MOTD. ESM FUD is spread throughout the OS including simple apt functions. You do not need ESM and thus Ubuntu 22.04 has become super annoying. unattended-upgrade is an automatic installation of security (and other) upgrades without user intervention. Consider the ramifications of disabling this service.

Disable unattended upgrades

The Unattended Upgrades feature is enabled by default and it runs at system boot without the user's permission. The configuration is stored in /etc/apt/apt.conf.d/20auto-upgrades

Disable: sudo dpkg-reconfigure unattended-upgrades then a TUI will come up, select "No"

This will not permantently disable the function. After an update it will be enabled. In the file /etc/apt/apt.conf.d/20auto-upgrades change these values from 1 to 0. Even doing this it will

@ricardodantas
ricardodantas / validacao+mascara.js
Last active April 18, 2024 21:11
Máscara e validação de RG, CNPJ, CPF, etc...
// JavaScript Document
// adiciona mascara para rg
// Cada estado têm regras e quantidades diferentes de números no registro. Por isso,
// não há uma maneira confiável de fazer a validação do mesmo.
function MascaraRg(v0,errChar='?'){
const v = v0.toUpperCase().replace(/[^\dX]/g,'');
return (v.length==8 || v.length==9)?
v.replace(/^(\d{1,2})(\d{3})(\d{3})([\dX])$/,'$1.$2.$3-$4'):
(errChar+v0)
@ptrstpp950
ptrstpp950 / preRequestScript.js
Last active April 18, 2024 21:10
Calculate TOTP in Postman
//Article about TOTP on my blog https://stapp.space/generate-totp-in-postman/
/**
* @preserve A JavaScript implementation of the SHA family of hashes, as
* defined in FIPS PUB 180-4 and FIPS PUB 202, as well as the corresponding
* HMAC implementation as defined in FIPS PUB 198a
*
* Copyright Brian Turek 2008-2017
* Distributed under the BSD License
* See http://caligatio.github.com/jsSHA/ for more information
@bradtraversy
bradtraversy / docker-help.md
Last active April 18, 2024 21:04
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@26medias
26medias / automl-vision-node.js
Last active April 18, 2024 21:04
Google Automl Vision: Using a trained tfjs model in NodeJS to classify an image (full working example)
const tf = require("@tensorflow/tfjs-node");
const automl = require("@tensorflow/tfjs-automl");
// Tensorflow Inference
var tfInference = {
loadDictionary: function(modelUrl) {
const lastIndexOfSlash = modelUrl.lastIndexOf("/");
const prefixUrl = lastIndexOfSlash >= 0 ? modelUrl.slice(0, lastIndexOfSlash + 1) : "";
const dictUrl = path.normalize(path.dirname(modelUrl)+'/dict.txt');
const text = fs.readFileSync(dictUrl, { encoding: "utf-8" });
@lukehedger
lukehedger / ffmpeg-compress-mp4
Last active April 18, 2024 21:00
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@lpnam0201
lpnam0201 / enumerate-dir-with-more-than-100-files.js
Created January 30, 2020 16:44
FileSystemDirectoryReader.readEntries() only returns 100 entries a time, must be called repeatedly to enumerate all entries.
function readEntriesAsync(reader) {
return new Promise((resolve, reject) => {
reader.readEntries(entries => {
resolve(entries);
}, error => reject(error));
})
}
async function enumerateDirectoryWithManyFiles(directoryEntry) {
let reader = directoryEntry.createReader();
@panzi
panzi / portable_endian.h
Last active April 18, 2024 20:59
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, Mac OS X, and QNX. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put …
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
@ABCxFF
ABCxFF / wasmfunc.polyfill.js
Created February 25, 2024 03:44
async WebAssembly.Function polyfill
// For Firefox or other browsers that don't provide WebAssembly.Function APIs,
// this polyfill, albeit async, can be used as a substitute.
//
// Using WASM, this polyfill is accepted by WebAssembly.Tables, and can be inserted
// into them without failure
if (!WebAssembly.Function) {
const vu32 = (x) => {
let out = [];
do {
let byte = x & 0x7F;
{#
/**
* @file
* Theme override to display a view of unformatted rows.
*
* Available variables:
* - title: The title of this group of rows. May be empty.
* - rows: A list of the view's row items.
* - attributes: The row's HTML attributes.
* - content: The row's content.