Skip to content

Instantly share code, notes, and snippets.

View thinkjrs's full-sized avatar
🎯
Focusing

Jason R. Stevens, CFA thinkjrs

🎯
Focusing
View GitHub Profile
@thinkjrs
thinkjrs / alt-ssh-copy-id.md
Created October 15, 2022 20:25 — forked from nickbayley/alt-ssh-copy-id.md
Simple Alternative to ssh-copy-id

Simple Alternative to ssh-copy-id

Replace user with the name of the user you want to ssh as.

Replace the ip with the ip of the machine / host / vps you want to connect to.

cat ~/.ssh/id_rsa.pub | ssh user@ip "cat >> ~/.ssh/authorized_keys"
@thinkjrs
thinkjrs / cloudinaryPayloadTypes.d.ts
Created October 8, 2022 14:02
Cloudinary TypeScript Payload Typing
type CloudinaryPayload = {
id: string;
batchId: string;
asset_id: string;
public_id: string;
version: number;
version_id: string;
signature: string;
width: number;
height: number;
@thinkjrs
thinkjrs / cookie-consent-implementation.md
Created August 30, 2022 18:01
A short how-to on how we implement react-cookie-consent at Tincre.
@thinkjrs
thinkjrs / flask_migrate_single_to_multidb.md
Created June 13, 2022 19:37
Flask-Migrate: Add multiple database setup to existing single database setup

Today we ran into an issue adding a multi-database setup to prior single-db setup. Here's how we fixed it and reference links.

What to do

From the maintainer of Flask-Migrate, Miguel Grinberg:

I was able to convert a single-db repository to multi-db with the following procedure:

  • backup everything just in case!
  • rename your migrations folder to something else (i.e. migrations-old)
@thinkjrs
thinkjrs / simple_testing_in_go.md
Created May 30, 2022 04:02
Writing tests in Go

"You write a test by creating a file with a name ending in _test.go that contains functions named TestXXX with signature func (t *testing.T). The test framework runs each such function; if the function calls a failure function such as t.Error or t.Fail, the test is considered to have failed."

📓 Reference: https://go.dev/doc/code.

Testing reverse.go

To test a file named reverse.go simply create a file named reverse_test.go in the package directory with the following content:

@thinkjrs
thinkjrs / remove_module_deps_go.md
Created May 29, 2022 14:22
Remove downloaded modules dependencies in Go

"To remove all downloaded modules, you can pass the -modcache flag to go clean:"

go clean -modcache

📓 Reference: https://go.dev/doc/code

@thinkjrs
thinkjrs / aws-s3-public-image-upload
Created April 10, 2022 01:33
Script to upload a local file to an s3 bucket as public returning the https route
#! /usr/bin/sh
# A simple script to upload the file given via the single input parameter
# via the full path to the file.
# This uses Python to grab the filename, since bash and other shell
# scripting languages are comparably unreadable.
bucket_name=<that-sexy-bucket-name-of-yours>
bucket=s3://$bucket_name/
input=$1
filename=$(python3 -c "print('$1'.split('/')[-1])")
@thinkjrs
thinkjrs / bash_git_funcs.md
Last active April 15, 2022 18:45
Git functions

Various git functions I use in my bash_aliases

gd() {
    git diff $1
}
gb() {
	git rev-parse --abbrev-ref HEAD
}
ga() {
@thinkjrs
thinkjrs / fileMock.js
Created March 25, 2022 15:16
Basic Next.js Test Setup jest + react testing library
// __mocks__/fileMock.js
module.exports = {
src: '/img.jpg',
height: 24,
width: 24,
blurDataURL: 'data:image/png;base64,imagedata',
}
@thinkjrs
thinkjrs / installing-git-from-source.md
Created March 17, 2022 17:41
Update to latest Git on Rhel/CentOS/Rocky systems