Skip to content

Instantly share code, notes, and snippets.

View lalilaloe's full-sized avatar

Jonathan ten Hove lalilaloe

View GitHub Profile
@lalilaloe
lalilaloe / ReadonlytoWritable.md
Created April 25, 2024 19:54
Javascript readonly nested array to writable

In case you ever need an readonly nested array to be writable again. It also checks if the object is configurable, TypeError: can't redefine non-configurable property. If it is not configurable there is no other way than to find another solution, such as recreating {...item}

Object.keys(new MyClass()).forEach(field => {
        if(Object.hasOwn(item, field)){
        // Check if the property is configurable
          const descriptor = Object.getOwnPropertyDescriptor(item, field);
          if (descriptor && !descriptor.configurable) {
 // Make the property configurable
@lalilaloe
lalilaloe / Auto login local user.md
Created December 8, 2023 11:10
Windows 11 auto login
  1. run (win + R) control userpasswords2 and uncheck Users must enter a user name and password to use this PC

If checkbox not visible:

  1. regedit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device
  2. 32-Bit DWORD value DevicePasswordLessBuildVersion or modify existing, set to 0 instead of 2 (default)
  3. run (win + R) control userpasswords2 and uncheck Users must enter a user name and password to use this PC
@lalilaloe
lalilaloe / Restore local user.md
Last active December 7, 2023 21:05
Accidental linked or login with microsoft account on local user
  1. Remove your microsoft account folder with (win + R) regedit.exe in HKEY_USERS\.DEFAULT\Software\Microsoft\IdentityCRL\StoredIdentities
  2. Remove pictures in %appdata%\Microsoft\Windows\AccountPictures
  3. restart
@lalilaloe
lalilaloe / Windows to WSL2 localhost access.md
Last active April 25, 2024 09:57
Windows to WSL2 localhost access, ex. Mongodb

I basically avoided this issue by using WSL1 for the past years, but I found a solution that works for me; If you don't encounter this issue often just use $(hostname).local 😒

TLDR; This changes localhost to point to your Windows IP, 127.0.0.1 is still available for wsl. In windows you can access WSL via localhost as usual, because windows listens for exposed ports on WSL. Exposes your set windows port(s) via portproxies.

  1. Add this to your /etc/wsl.conf,
[boot]
command="sed -i \"s/127.0.0.1$(printf '\t')localhost/$(tail -1 /etc/resolv.conf | cut -d' ' -f2)$(printf '\t')localhost/g\" /etc/hosts 2>&1"
@lalilaloe
lalilaloe / gist:fe894ce43a29cb7e0a7bf591fda3d612
Created November 18, 2021 13:21
FizzBuzz some javascript oneliners
console.log(Array(100).fill(" Fizz Buzz").map((r, i) => i++ && r.split(" ").filter((v, n) => v && i % n == 0).join('') || i).join("\n"));
Array(100).fill(" Fizz Buzz").map((r, i) => console.log(i++ && r.split(" ").filter((v, n) => v && i % n == 0).join('') || i));
Array(100).fill([, , , "Fizz", , "Buzz"]).map((r, i) => console.log(i++ && r.filter((v, n) => v && i % n == 0).join('') || i));
Array(100).fill().map((r, i) => console.log(i++ && [, , , "Fizz", , "Buzz"].filter((v, n) => v && i % n == 0).join('') || i));
Array.from({ length: 100 }, (_, i) => console.log(i++ && [, , , "Fizz", , "Buzz"].filter((v, n) => v && i % n == 0).join('') || i));
[...new Array(100)].map((_, i) => console.log(i++ && Object.entries({ 3: "Fizz", 5: "Buzz" }).filter(n => i % n[0] == 0).map(n => n[1]).join('') || i));
@lalilaloe
lalilaloe / encryption.js
Created January 15, 2019 10:29
Encryption Encrypted Request Bunq
const forge = require("node-forge");
const hex2bin = str => str.match(/.{1,2}/g).reduce((str, hex) => str += String.fromCharCode(parseInt(hex, 16)), '');
const ivRaw = hex2bin("9916624005aff27d337cb4710065eb84");
const keyRaw = hex2bin("b4086697c4fa9af691ca18c49635e5d8930afed8051b3a10ce77d3997dcd10c2");
const bodyRaw = "test"
const HMAC_ALGORITHM = "sha1";
const AES_ENCRYPTION_METHOD = "AES-CBC";
function generateHmac(key, iv, body) {
const content = iv + body;
@lalilaloe
lalilaloe / EncryptRequestHandler.ts
Created December 11, 2018 13:42
EncryptRequestHandler using crypto libary
import * as forge from "node-forge";
import BunqJSClient from "../BunqJSClient";
import Session from "../Session";
import LoggerInterface from "../Interfaces/LoggerInterface";
import Request from "./Request";
var crypto = require('crypto');
import ApiAdapterOptions from "../Types/ApiAdapterOptions";
const HEADER_CLIENT_ENCRYPTION_HMAC = "X-Bunq-Client-Encryption-Hmac";