Skip to content

Instantly share code, notes, and snippets.

@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 1, 2024 03:05
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 May 2, 2024 19:03
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 4, 2024 00:30
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)
@gfinol
gfinol / Nextcloud-Pi3-Setup.md
Created November 4, 2017 01:18 — forked from ronau/Nextcloud-Pi3-Setup.md
Nextcloud on Raspberry Pi 3 Setup

Nextcloud on Raspberry Pi 3 Setup

This manual describes how to setup a Raspberry Pi 3 with nginx, PHP 7.0, MariaDB and use it as a Nextcloud server. Strong TLS encryption with Let's Encrypt certificates is also used. Of course, Owncloud can be used instead of Nextcloud. As of February 2017, the installation instructions are basically the same.

Useful links and knowledge sources for this step-by-step manual