Skip to content

Instantly share code, notes, and snippets.

@JonCole
JonCole / Redis-BestPractices-General.md
Last active April 18, 2024 07:57
Redis Best Practices

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@anonymous1184
anonymous1184 / Ini.ahk
Last active April 18, 2024 07:57
Automatic configuration file handling.
; Version: 2023.04.20.1
; Usages and examples: https://redd.it/s1it4j
Ini(Path, Sync := true) {
return new Ini_File(Path, Sync)
}
class Ini_File {
@j4w8n
j4w8n / implement-user-api-keys-with-supabase.md
Last active April 18, 2024 07:56
Implement user API keys with Supabase

Implement user API keys with Supabase

Rationale

JWTs are at the heart of Supabase authorization, but sometimes we wanna build an app that also gives users access via API keys; or perhaps only exclusively via API keys. As you may know, using JWTs as API keys makes them difficult to revoke and therefore a security issue.

We also want to ensure this doesn't significantly add to RLS polices, if at all.

Finally, we'd love to have this handled by Supabase and do as little as possible in our framework. This simplifies our code and reduces third-party libraries.

Solution

@warwickchapman
warwickchapman / dynDns.rsc
Last active April 18, 2024 07:56
Mikrotik RouterOS 7 Cloudflare DNS Record Update
# Prerequisites
# - A Cloudflare account and a domain managed by Cloudflare.
# - The Zone ID of your domain in Cloudflare. You can find this in the Cloudflare dashboard under your domain's overview tab.
# - An API token with permissions to edit DNS records. You can create this in the Cloudflare dashboard under "My Profile" > "API Tokens".
# Creating an API Token in Cloudflare
# - Go to Cloudflare Dashboard > My Profile > API Tokens.
# - Click "Create Token".
# - Use the "Edit zone DNS" template.
# - Set permissions for the specific zone (domain) you wish to update via DDNS.
@SoabY
SoabY / JetBrains products Activation code until 15 May 2024
Created October 1, 2023 08:04
JetBrains products Activation code until 15 May 2024
8Z6IT0PIZH-eyJsaWNlbnNlSWQiOiI4WjZJVDBQSVpIIiwibGljZW5zZWVOYW1lIjoiSHVuYW4gTm9ybWFsIFVuaXZlcnNpdHkiLCJhc3NpZ25lZU5hbWUiOiJTdGFyayB6aGFuZyIsImFzc2lnbmVlRW1haWwiOiJzdGFyazE5ODUyMDIwQGdtYWlsLmNvbSIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiRFBOIiwicGFpZFVwVG8iOiIyMDI0LTA1LTE1IiwiZXh0ZW5kZWQiOmZhbHNlfSx7ImNvZGUiOiJEQiIsInBhaWRVcFRvIjoiMjAyNC0wNS0xNSIsImV4dGVuZGVkIjpmYWxzZX0seyJjb2RlIjoiUFMiLCJwYWlkVXBUbyI6IjIwMjQtMDUtMTUiLCJleHRlbmRlZCI6ZmFsc2V9LHsiY29kZSI6IklJIiwicGFpZFVwVG8iOiIyMDI0LTA1LTE1IiwiZXh0ZW5kZWQiOmZhbHNlfSx7ImNvZGUiOiJSU0MiLCJwYWlkVXBUbyI6IjIwMjQtMDUtMTUiLCJleHRlbmRlZCI6dHJ1ZX0seyJjb2RlIjoiR08iLCJwYWlkVXBUbyI6IjIwMjQtMDUtMTUiLCJleHRlbmRlZCI6ZmFsc2V9LHsiY29kZSI6IkRNIiwicGFpZFVwVG8iOiIyMDI0LTA1LTE1IiwiZXh0ZW5kZWQiOmZhbHNlfSx7ImNvZGUiOiJSU0YiLCJwYWlkVXBUbyI6IjIwMjQtMDUtMTUiLCJleHRlbmRlZCI6dHJ1ZX0seyJjb2RlIjoiRFMiLCJwYWlkVXBUbyI6IjIwMjQtMDUtMTUiLCJleHRlbmRlZCI6ZmFsc2V9LHsiY29kZSI6IlBDIiwicGFpZFVwVG8iOiIyMDI0LTA1LTE1IiwiZ
@wfrisch
wfrisch / http-serve-incomplete-responses.py
Created February 1, 2024 09:15
Deliberately broken HTTP server that responds with either a) false Content-Length or b) broken chunked encoding
#!/usr/bin/env python3
"""
Deliberately broken HTTP server that responds with either
- false Content-Length
- broken chunked encoding
both triggering ChunkedEncodingError in clients using `python-requests`:
- ChunkedEncodingError: Connection broken: IncompleteRead
- ChunkedEncodingError: Connection broken: InvalidChunkLength
"""
@loilo
loilo / base64.mjs
Last active April 18, 2024 07:52
URL-Safe LZMA Compression
/**
* Convert between Uint8Array and Base64 strings
* Allows for any encoded JS string to be converted (as opposed to atob()/btoa() which only supports latin1)
*
* Original implementation by madmurphy on MDN
* @see https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#Solution_1_–_JavaScript%27s_UTF-16_%3E_base64
*/
function b64ToUint6(nChr) {
return nChr > 64 && nChr < 91
@hyOzd
hyOzd / delete-file-and-buffer.el
Created July 21, 2015 11:55
emacs delete current file and close the buffer
;; based on http://emacsredux.com/blog/2013/04/03/delete-file-and-buffer/
(defun delete-file-and-buffer ()
"Kill the current buffer and deletes the file it is visiting."
(interactive)
(let ((filename (buffer-file-name)))
(if filename
(if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
(progn
(delete-file filename)
(message "Deleted file %s." filename)
@girip11
girip11 / mac_os_kb_ubuntu_like.md
Last active April 18, 2024 07:50
Configuring Mac OS keyboard shortcuts to resemble Ubuntu

Setup MacOS shortcuts to be same as Ubuntu

I have been using Ubuntu for last few years. Now I have to work on Mac OS for work. But I still use personal laptop which has Ubuntu. So I decided to setup the Mac OS shortcuts to be exactly same as in Ubuntu.

Prerequisites