Skip to content

Instantly share code, notes, and snippets.

View benjaminvanrenterghem's full-sized avatar
🟢

Benjamin Van Renterghem benjaminvanrenterghem

🟢
View GitHub Profile
@rmorse
rmorse / react-router-dom-v.6.02.prompt.blocker.js
Last active June 5, 2024 15:56
Adds back in `useBlocker` and `usePrompt` to `react-router-dom` version 6.0.2 (they removed after the 6.0.0 beta, temporarily)
/**
* These hooks re-implement the now removed useBlocker and usePrompt hooks in 'react-router-dom'.
* Thanks for the idea @piecyk https://github.com/remix-run/react-router/issues/8139#issuecomment-953816315
* Source: https://github.com/remix-run/react-router/commit/256cad70d3fd4500b1abcfea66f3ee622fb90874#diff-b60f1a2d4276b2a605c05e19816634111de2e8a4186fe9dd7de8e344b65ed4d3L344-L381
*/
import { useContext, useEffect, useCallback } from 'react';
import { UNSAFE_NavigationContext as NavigationContext } from 'react-router-dom';
/**
* Blocks all navigation attempts. This is useful for preventing the page from
* changing until some condition is met, like saving form data.
@technikhil314
technikhil314 / generateDigest.js
Last active November 30, 2023 09:55
Generate sha-256 hash using crypto in browsers
const text = 'An obscure body in the S-K System, your majesty. The inhabitants refer to it as the planet Earth.';
async function digestMessage(message) {
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashHex;
}
@IanColdwater
IanColdwater / twittermute.txt
Last active May 23, 2024 18:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@eddiez9
eddiez9 / feedly.opml
Last active December 21, 2023 03:09
Collection of RSS feeds to keep up with cyber news.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>OPML export</title>
</head>
<body>
<outline text="Forums - IT Security" title="Forums - IT Security">
<outline text="/r/netsec - Information Security News &amp; Discussion" title="/r/netsec - Information Security News &amp; Discussion" type="rss" xmlUrl="http://www.reddit.com/r/netsec/.rss" htmlUrl="http://www.reddit.com/r/netsec/"/>
<outline text="IT Security - Hot Weekly Questions" title="IT Security - Hot Weekly Questions" type="rss" xmlUrl="http://security.stackexchange.com/feeds/week" htmlUrl="http://security.stackexchange.com/questions"/>
</outline>
@icook
icook / cruz_cli.py
Created September 10, 2019 20:01
A simple click based CLI for cruzbit
# pip3 install --user click websocket_client
import json
import binascii
import hashlib
import sys
import pprint
import logging
import ssl
import websocket
@GetoXs
GetoXs / ServiceCollectionExtentions.cs
Last active March 2, 2024 06:06
Register All Types (with Generic) in .NET Core DependencyInjection
using System;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
public static class ServiceCollectionExtentions
{
public static void AddAllTypes<T>(this IServiceCollection services
, Assembly[] assemblies
, bool additionalRegisterTypesByThemself = false
public class RevalidatingAuthenticationStateProvider : AuthenticationStateProvider, IDisposable
{
private static TimeSpan RefreshInterval = TimeSpan.FromMinutes(30);
private readonly CancellationTokenSource _cts;
private ClaimsPrincipal _currentUser;
public RevalidatingAuthenticationStateProvider(SignInManager<IdentityUser> signInManager)
{
_cts = new CancellationTokenSource();
@dima056359
dima056359 / setup.sh
Created January 17, 2019 20:00
Ubuntu 16.04 tightvncserver setup script
#!/bin/bash
# Update repos
sudo apt update
# Install XFCE4
echo "----Install Xubuntu-desktop"
sudo apt install xfce4 xfce4-goodies -y
echo "----Install VNC Server"
@Tras2
Tras2 / cloudflare-ddns-update.sh
Last active May 31, 2024 11:55
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/bin/bash
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
# Used to provide DDNS service for my home
# Needs the DNS record pre-creating on Cloudflare
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
@deerwood-mccord-jr
deerwood-mccord-jr / INotifyPropertyChangedLambda.cs
Created April 10, 2018 15:28
INotifyPropertyChangedLambda
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Sagentia.PgxGss.MainGuiDll.Support
{