Skip to content

Instantly share code, notes, and snippets.

View Forever-Young's full-sized avatar

Anton Novosyolov Forever-Young

View GitHub Profile
@brunolemos
brunolemos / v1.tsx
Created December 17, 2019 15:40
useWhyDidYouUpdate
import { useEffect, useRef } from 'react'
export function useWhyDidYouUpdate(name: string, props: Record<string, any>) {
const latestProps = useRef(props)
useEffect(() => {
const allKeys = Object.keys({ ...latestProps.current, ...props })
const changesObj: Record<string, { from: any; to: any }> = {}
allKeys.forEach(key => {
@gholker
gholker / download-aws-logs.sh
Last active August 26, 2024 14:00
Script that uses the aws cli to download cloudwatch logs to a file
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
LOG_GROUP_NAME=""
LOG_STREAM_NAME=""
REGION=""
OUTPUT_FILE="$(date +"%Y%m%d").log"
@ashfurrow
ashfurrow / Fresh macOS Setup.md
Last active September 19, 2024 12:27
All the stuff I do on a fresh macOS Installation

Apps to install from macOS App Store:

  • Pastebot
  • GIF Brewery
  • Slack
  • Keynote/Pages/Numbers
  • 1Password
  • OmniFocus 3
  • Airmail 3
  • iA Writer
@ripper
ripper / sshd_tunnel.sh
Last active June 27, 2023 16:09
A script to launch user sshd limited to creation of reverse tunnels
#!/bin/sh
AUTHORIZED_KEYS=authorized_keys
HOST_RSA_KEY=ssh_host_rsa_key
SSHD=/usr/sbin/sshd
PORT=8443
case "$AUTHORIZED_KEYS" in /*) ;; *) AUTHORIZED_KEYS=$PWD/$AUTHORIZED_KEYS ;; esac
case "$HOST_RSA_KEY" in /*) ;; *) HOST_RSA_KEY=$PWD/$HOST_RSA_KEY ;; esac
@untergrundbiber
untergrundbiber / oauth.sh
Last active February 3, 2022 20:49
YouTube OAuth Bash
#!/bin/bash
#YouTube OAuth authentication for shell-based YT-tools like youtube-dl
#by untergrundbiber 2014
#You need to register a app to obtaining clientId and clientSecret.
#https://developers.google.com/youtube/registering_an_application
#You can find the right scope here: https://developers.google.com/oauthplayground/
#--- Settings ---
clientId="000000000000.apps.googleusercontent.com"
@fiedl
fiedl / nas-e2fsck.sh
Created January 20, 2014 01:25
QNAP-NAS: How to check disk if cannot unmount when device is busy.
ssh admin@nas
/etc/init.d/services.sh stop
/etc/init.d/xdove.sh stop
# See if there are still files open on the disk:
lsof |grep /share/MD0_DATA
# Kill the open processes if any.
@hrldcpr
hrldcpr / tree.md
Last active September 1, 2024 07:04
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@aaugustin
aaugustin / admin.py
Last active August 7, 2022 19:39
Read-only ModelAdmin for Django
from django.contrib import admin
class ReadOnlyModelAdmin(admin.ModelAdmin):
"""
ModelAdmin class that prevents modifications through the admin.
The changelist and the detail view work, but a 403 is returned
if one actually tries to edit an object.