Skip to content

Instantly share code, notes, and snippets.

View k-yle's full-sized avatar
💙

Kyℓe Hensel k-yle

💙
View GitHub Profile
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import {
compose,
unless,
prop,
isNil,
merge,
propOr,
tryCatch,
import { useEffect, useRef, useReducer } from 'react';
import { merge, forEach, reject, append } from 'ramda';
export const useIsMounted = () => {
const ref = useRef(null);
useEffect(() => {
ref.current = true;
return () => {
ref.current = false;
};
@k-yle
k-yle / typed-getter.ts
Last active April 8, 2020 00:29
💙 returns a different type depending on the value of a function's argument
type Users = any;
type Timetables = any;
type AllTheTypes =
| { name: 'users'; type: Users }
| { name: 'timetables'; type: Timetables }
type GetType<A, T> = A extends { name: T } ? A : never
@carceneaux
carceneaux / remove_gitlab_artifacts.sh
Last active April 29, 2025 06:28
Script for removing GitLab Job Artifacts.
#!/bin/bash
#
# Written by Chris Arceneaux
# GitHub: https://github.com/carceneaux
# Email: [email protected]
# Website: http://arsano.ninja
#
# Note: This code is a stop-gap to erase Job Artifacts for a project. I HIGHLY recommend you leverage
# "artifacts:expire_in" in your .gitlab-ci.yml
#
@wybiral
wybiral / noscript-tracking.go
Last active October 28, 2024 23:01
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@bnoordhuis
bnoordhuis / bytestokey.js
Created November 29, 2017 22:55
Compute key+IV from passphrase (createCipher to createCipheriv migration script)
// Copyright (c) 2017, Ben Noordhuis <[email protected]>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@raduserbanescu
raduserbanescu / remove-mingw-text-from-git-bash-prompt.md
Last active December 22, 2023 19:38
Remove "MINGW" text from Git Bash prompt and window title

Remove "MINGW" text from Git Bash prompt and window title

Quickly remove the text without having to create a custom prompt.

Edit the file: C:\Program Files\Git\etc\profile.d\git-prompt.sh

 else
        TITLEPREFIX=$MSYSTEM
 fi
@chrisveness
chrisveness / crypto-pbkdf2.js
Last active December 16, 2024 17:21
Uses the SubtleCrypto interface of the Web Cryptography API to hash a password using PBKDF2, and validate a stored password hash against a subsequently supplied password. Note that both bcrypt and scrypt offer better defence against ASIC/GPU attacks, but are not available within WebCrypto.
/**
* Returns PBKDF2 derived key from supplied password.
*
* Stored key can subsequently be used to verify that a password matches the original password used
* to derive the key, using pbkdf2Verify().
*
* @param {String} password - Password to be hashed using key derivation function.
* @param {Number} [iterations=1e6] - Number of iterations of HMAC function to apply.
* @returns {String} Derived key as base64 string.
*
@k-yle
k-yle / SAMBA.markdown
Last active February 8, 2024 02:46
💻 How to get out of SAMBA mode on NXT

How to get out of SAMBA mode

(SAMBA = SAM Boot Assistant)

  • In device manager the brick had a device description Bossa Program Port. It should be LEGO MINDSTORMS NXT.
  • Uninstalling the driver and reinstalling it still shows Bossa Program Port.
  • So I found the hardware ID of the Bossa Program Port from device manager (USB\VID_03EB&PID_6124).
  • Then I went to the c:\Windows\inf directory and searched for that ID.
  • That ID appeared in two INF files oem11.inf and oem42.inf.
  • oem11.inf has the device description "LEGO MINDSTORMS NXT Firmware Update Mode" and oem42.inf has the description "Bossa Program Port".
  • So that's why it installed the wrong driver.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
var t = prompt("Enter text to be sent to console, (This wont send the enter keystroke)").split("");
function f() {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = "!@#$%^&*()_+{}:\"<>?~|".indexOf(character) !== -1