Skip to content

Instantly share code, notes, and snippets.

View todgru's full-sized avatar

todgru

  • Portland, OR
View GitHub Profile
@todgru
todgru / hey-gpt
Created March 29, 2023 22:18 — forked from senko/hey-gpt
Small bash script to use ChatGPT from command line
#!/bin/bash
if test -z "$1"; then
echo "Usage: $0 <prompt>"
exit 1
fi
if test -z "$OPENAI_API_KEY"; then
echo "OpenAI key is missing - \$OPENAI_API_KEY must be set"
exit 1
@todgru
todgru / esm-package.md
Created October 7, 2022 20:41 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@todgru
todgru / s3push.sh
Created August 9, 2022 18:42 — forked from ambanmba/s3push.sh
CurlPushToS3
#!/bin/bash
fileLocal="filename.ext"
bucket="name-of-bucket"
s3dir="nameofdirectory/"
region="us-east-2"
storageClass="STANDARD"
awsAccess='XXXXXXXXXXXXXXXXXXXX'
awsSecret='0000000000aaaaaaaaaa0000000000aaaaaaaaaa' #Make sure to use credentials with WRITE access to the bucket
@todgru
todgru / aws-signature-creator.sh
Created August 9, 2022 18:41 — forked from adrianbartyczak/aws-signature-creator.sh
A signature creator for AWS signature version 4
#!/usr/bin/env bash
#
# File:
# aws-signature-creator.sh
#
# Description:
# A signature creator for AWS signature version 4
#
# References:
# https://czak.pl/2015/09/15/s3-rest-api-with-curl.html
@todgru
todgru / rect-starlink-cable-hack.md
Created August 1, 2022 00:22 — forked from darconeous/rect-starlink-cable-hack.md
Hacking the Rectangular Starlink Dishy Cable
@todgru
todgru / parse_ini.sh
Created February 9, 2021 01:38 — forked from wyllie/parse_ini.sh
Parse aws credentials file in bash
#!/usr/bin/env bash
INI_FILE=~/.aws/credentials
while IFS=' = ' read key value
do
if [[ $key == \[*] ]]; then
section=$key
elif [[ $value ]] && [[ $section == '[default]' ]]; then
if [[ $key == 'aws_access_key_id' ]]; then

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@todgru
todgru / README.md
Created December 19, 2020 00:14 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")

Transparent Git Encryption

This document has been modified from its [original format][m1], which was written by Ning Shang (geek@cerias.net). It has been updated and reformatted into a [Markdown][m2] document by [Woody Gilk][m3] and [republished][m4].

Description

When working with a remote git repository which is hosted on a third-party storage server, data confidentiality sometimes becomes

@todgru
todgru / post-receive
Created April 28, 2020 21:59 — forked from tlrobinson/post-receive
Super simple git post-receive hook for Node.js + nvm + npm + node-foreman + init (Ubuntu) deployment
#!/usr/bin/env bash
set -u
set -e
export GIT_WORK_TREE="/var/www/example.com"
export NODE_VERSION="0.10"
echo "--> Checking out..."
git checkout -f