Skip to content

Instantly share code, notes, and snippets.

View christ776's full-sized avatar

Christian De Martino christ776

View GitHub Profile
@KristofferEriksson
KristofferEriksson / useIdle.ts
Created January 25, 2024 10:26
React Hook to detect user inactivity based on specified events like mouse movements, touch events or key presses
import { useEffect, useState } from "react";
const defaultEvents = [
"mousemove",
"mousedown",
"touchstart",
"keydown",
"wheel",
"resize",
];
@eoamusan
eoamusan / prettify.js
Last active November 13, 2022 10:29
javascript - prettity
function doStuff(text) {
// Convert the text to lower characters
const lowerCased = text.toLocaleLowerCase();
// Split the characters with the space delimeter
const words = lowerCased.split(' ');
// Reverse split array
words.reverse();
@GeoffreyCoulaud
GeoffreyCoulaud / README.md
Last active December 21, 2023 01:59
PROOF OF CONCEPT - Installing TeknoParrot on Linux

Installing TeknoParrot on Linux

⚠️ You should not execute scripts that you don't understand and trust from the internet.

1. Using Lutris

Both methods need you to provide a teknoparrot release archive. You can find it here.

Install from Lutris' website

Note : TeknoParrot is at the moment pending on Lutris.net, and so is my installer. You can find my install script on Lutris

@jonathanpalma
jonathanpalma / useYupValidationResolver.ts
Last active March 7, 2023 16:36
Type-safe react hook to use yup validation resolver with react-hook-form
import { useCallback } from 'react';
import { object, ValidationError } from 'yup';
const useYupValidationResolver = (
validationSchema: ReturnType<typeof object>
) =>
useCallback(
async (data) => {
try {
const values = await validationSchema.validate(data, {
@jonathanws
jonathanws / mocking-with-sinon-sandbox.js
Last active October 5, 2021 19:41
Testing AWS services with Sinon mocks in Lambda
/**
* Writing tests for functions that use external dependencies is tough.
* We can get past this by using sinon sandboxes to temporarily overwrite the
* prototypes of those dependencies, just for testing
*
* Before running these tests run:
* $ npm install --save-dev aws-sdk sinon mocha
*/
/**
@mobilequickie
mobilequickie / DefineAuthChallenge.js
Last active August 4, 2023 03:46
Amazon Cognito CUSTOM_CHALLENGE Lambda trigger - Define Auth Challenge function
// ### About this Flow ###
// Using Custom Auth Flow through Amazon Cognito User Pools with Lambda Triggers to complete a 'CUSTOM_CHALLENGE'. This is the same flow as one-time passcode generated and sent via SMS or Email.
// Instead, the service and user share a secret that was created during registration and both generate a 6-digit code based on the shared secret.
// If the two codes (typically only good for 30 seconds) match, the user is authenticated.
//
// ### About this function ###
// This DefineAuthChallengeCustom function (1st and 4th of 4 triggers) defines the type of challenge-response required for authentication.
// For HOTP, TOTP, U2F, or WebAuthn flows, we'll always use 'CUSTOM_CHALLENGE' and this function code won't change between the various auth methods.
// ### Next steps ###
@coenraadhuman
coenraadhuman / inotify.md
Last active April 23, 2024 09:09
Increasing the amount of inotify watchers

Increasing the amount of inotify watchers

Take note this is my personal edited version and the command related to Arch has been changed to work on my Arch system.

Increase inotify watchers

@phleagol
phleagol / binge
Created June 3, 2019 05:44
binge
#!/usr/bin/perl
##
## binge - curses torrent client with 'top' mode.
##
## keys - Press 'h' to show key bindings, then ESC.
##
## urxvt -name binge -n binge -T binge -e sh -c "exec binge 2>>/tmp/binge_$(date +%s).log"
##
## apt-install libcurses-perl libwww-perl libjson-maybexs-perl libjson-xs-perl libdata-dump-perl
## libmath-round-perl libtext-unidecode-perl transmission-daemon
@GeorgioWan
GeorgioWan / Hex_Base64.js
Last active November 10, 2022 14:21
Hex & Base64 Encode Decode
// Hex to Base64
function hexToBase64(str) {
return btoa(String.fromCharCode.apply(null,
str.replace(/\r|\n/g, "").replace(/([\da-fA-F]{2}) ?/g, "0x$1 ").replace(/ +$/, "").split(" "))
);
}
// Base64 to Hex
function base64ToHex(str) {
for (var i = 0, bin = atob(str.replace(/[ \r\n]+$/, "")), hex = []; i < bin.length; ++i) {
##
## Supermodel
## A Sega Model 3 Arcade Emulator.
## Copyright 2011-2016 Bart Trzynadlowski, Nik Henson
##
## This file is part of Supermodel.
##
## Supermodel is free software: you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free
## Software Foundation, either version 3 of the License, or (at your option)