Skip to content

Instantly share code, notes, and snippets.

@srelbo
srelbo / get_clerk_users.py
Last active May 18, 2024 15:49
Query clerk to get all users into a CSV file for https://loops.so import
import os
import requests
import csv
import time
def fetch_all_users(api_key):
url = "https://api.clerk.dev/v1/users"
headers = {
"Authorization": f"Bearer {api_key}",
@zh4n7wm
zh4n7wm / generate-signed-urls-and-cookies-for-cloudfront-with-python-and-golang.md
Last active July 12, 2023 21:27
AWS CloudFront generate signed urls and cookies with Python and Golang
@fractalliter
fractalliter / transaction.c
Last active May 7, 2023 19:21
A transactional query on postgresql
#include <libpq-fe.h>
#include <stdio.h>
#include <stdlib.h>
void close_connection(PGconn *connection, int code) {
PQfinish(connection);
exit(code);
}
// If the retrieved data is not a tuble
@leongjinqwen
leongjinqwen / upload-to-aws-flask.md
Created January 23, 2020 15:32
upload files to aws s3 bucket with flask

Upload files to AWS

Make sure you already have S3 bucket, access key and secret key before go through this notes.

How to connect to AWS?

Boto3 allows Python developers to write software that makes use of services like Amazon S3 and Amazon EC2.

Step 1: Install boto3 with pip

pip install boto3
@movsb
movsb / tunnel.go
Created December 6, 2019 14:50
An HTTP Tunnel Proxy, which implements the CONNECT method. Written in Golang, within 100 lines of code.
package main
import (
"io"
"log"
"net"
"net/http"
"sync"
)
@topherPedersen
topherPedersen / no-flash-on-button-click.html
Last active November 30, 2023 11:35
How to Prevent a Button from Changing its Border and Background Color in CSS When Clicked
<!DOCTYPE html>
<html>
<head>
<style>
.noFlash {
/* Remove onclick Background Color Change */
/* REFERENCE: https://bit.ly/2Yc95wR */
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
@RRethy
RRethy / gist:ad8a9a3b1112a48226ec3336fa981224
Last active May 19, 2024 10:48
Seamlessly editing remote files in (Neo)Vim with Netrw and scp

Seamlessly editing remote files in (Neo)Vim with Netrw and scp

Neovim and Vim both come bundled with a standard plugin called Netrw. Netrw acts a file explorer (similar to NERDTree), but more importantly has the ability to work with scp (as well as sftp, rcp, ftp, and lots of others :h netrw-nread) to let you edit files and browse directories that are hosted on a remote machine, inside of your local Vim instance.

This is useful since you are able to use your Vim setup and plugins without copying over your dotfiles to the remote machine. As well, since the file is copied to your local machine, there will be no delay when typing.

Setup

This is optional for Vim, but required for Neovim (check this Neovim issue explaining why).

@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active July 2, 2024 06:23
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@pseudomuto
pseudomuto / main_1.go
Last active May 23, 2024 17:03
Blog Code: Clean SQL Transactions in Golang
package main
import (
"database/sql"
"log"
)
func main() {
db, err := sql.Open("VENDOR_HERE", "YOUR_DSN_HERE")
handleError(err)