Skip to content

Instantly share code, notes, and snippets.

View ScreamZ's full-sized avatar

Andréas Hanss ScreamZ

View GitHub Profile
@nebhead
nebhead / CustomUSBName.md
Last active May 21, 2024 03:47
Instructions for Adding Custom Naming for Arduino USB Device

The following is capturing instructions on how to add custom naming for an Arduino Leonardo (or generic pro-micro) for my Arcade Controller device. I wanted to have a simple record so that when I inevitably come back to this someday I can recall how I accomplished this. Reference was taken from the following YouTube video (https://youtu.be/hoCOq9Ngp44?t=1156) at approximately 19m16s.

WINDOWS Instructions:

Create a new set of folders: ~\Documents\Arduino\hardware\daemonbite\avr

Copy everything from C:\Program Files (x86)\Arduino\hardware\arduino\avr to this new folder.

@beatfactor
beatfactor / 01 – Running serialport in Docker with node alpine.md
Last active March 20, 2023 15:21
Running serialport in Docker with node alpine

When attempting to build the awesome serialport NPM package in Docker using a node alpine image, in usually failes on building the node-gyp package.

There are various workarounds which can be found online, such as this one.

However, the key ingredient is building the serialport package from source, using this line:

npm install serialport --build-from-source=serialport
@patmigliaccio
patmigliaccio / now-secrets-json.js
Created May 12, 2019 01:23
Adds secret keys from local JSON files as Base64 to `now` secrets.
const fs = require('fs');
const GOOGLE_APPLICATION_CREDENTIALS = 'keys/google_application_credentials.json';
/**
* Adds secret keys from local JSON files as Base64 to `now` secrets.
*
* e.g. `node now-secrets-json.js'
*/
function main() {
@cecilemuller
cecilemuller / launch.json
Last active May 16, 2024 16:38
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@loilo
loilo / bubble.md
Last active April 27, 2023 00:21
Make Vue events bubble

Make Vue events bubble

Vue events don't bubble the component tree on their own. However when writing wrapper components this can be the desired behaviour.

This code registers a global bubble directive which allows to re-emit all given events:

Let's say we want to bubble events start, accelerate and brake of our component Car.

Without any help, we'd roughly have to do this:

@addyosmani
addyosmani / workbox.md
Last active January 20, 2024 16:14
Workbox recipes

Workbox runtime caching recipes

Your Service Worker script will need to import in Workbox and initialize it before calling any of the routes documented in this write-up, similar to the below:

importScripts('workbox-sw.prod.v1.3.0.js');
const workbox = new WorkboxSW();

// Placeholder array populated automatically by workboxBuild.injectManifest()
@zfael
zfael / nodejs.checksum.js
Created June 20, 2017 13:57
NODE.JS - How to generate file's Checksum (CRYPTO)
var fs = require('fs');
var crypto = require('crypto');
fs.readFile('file.pdf', function(err, data) {
var checksum = generateChecksum(data);
console.log(checksum);
});
function generateChecksum(str, algorithm, encoding) {
return crypto
@knadh
knadh / zsh-elapsed-time.md
Last active May 15, 2024 19:22
Elapsed and execution time for commands in ZSH

Elapsed and execution time display for commands in ZSH

Append this to your ~/.zshrc file.

function preexec() {
 timer=$(($(date +%s%0N)/1000000))
@joepie91
joepie91 / random.md
Last active May 19, 2024 18:16
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

anonymous
anonymous / a.rb
Created October 9, 2016 02:40
copy/paste to terminal> inxi -Fxxrzc0 | pastebin # <-- everything from '>' up to '#' is the command, share the link/url output in chat.
1. you are going to share output from 'inxi' https://github.com/smxi/inxi and
2. that outupt is going to go to a anymouse pastebin,
3. the 'pastebin' command sends it to 'gist' aka github pastebin, https://gist.github.com/
4. you see the link before anyone else, look at it, then share it,
5. is it safe? the 'z' option forces the mask of 'mac id's' , everything else i would not care who knows.
6. google does not index an anymouse gist, meaning its not going to haunt you later.