Skip to content

Instantly share code, notes, and snippets.

View Fallenstedt's full-sized avatar
:octocat:
Having fun

Alexander Fallenstedt Fallenstedt

:octocat:
Having fun
View GitHub Profile
@Fallenstedt
Fallenstedt / sync.sh
Last active April 9, 2024 16:12
Syncs upstream branch with local branch
#!/bin/bash
if [ -d ".git" ]; then
echo "git repo detected"
echo "checking out $1..."
git checkout $1
echo "fetching origin $1..."
git fetch origin $1
echo "merging origin $1 to local $1..."
git merge origin/$1
echo "done"
@Fallenstedt
Fallenstedt / redirectExample.go
Created January 1, 2024 01:32 — forked from knibals/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
)
func redirect(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req,
"https://" + req.Host + req.URL.String(),
http.StatusMovedPermanently)
}
@Fallenstedt
Fallenstedt / rename
Created July 29, 2023 22:38
Rename files with counter in directory
ls -v | cat -n | while read n f; do mv -n "$f" "$n.ext"; done
@Fallenstedt
Fallenstedt / encrypt_decrypt.go
Created November 12, 2020 05:53
Encrypting and Decrypting in go
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
)
@Fallenstedt
Fallenstedt / use-daedalus-socket-cardano-cli.sh
Created November 7, 2021 18:58 — forked from ilyar/use-daedalus-socket-cardano-cli.sh
Use Daedalus socket for cardano-cli for Mainnet or Testnet the Cardano
#!/usr/bin/env bash
# Install cardano-cli or use docker https://gist.github.com/ilyar/bf4c2346be1a74c50e488181986808fb
#
# Linux https://hydra.iohk.io/job/Cardano/cardano-node/cardano-node-linux/latest-finished
# Win64 https://hydra.iohk.io/job/Cardano/cardano-node/cardano-node-win64/latest-finished
# Macos https://hydra.iohk.io/job/Cardano/cardano-node/cardano-node-macos/latest-finished
# Extcact only cardano-cli into /usr/local/bin/cardano-cli
# Check
cardano-cli --version
@Fallenstedt
Fallenstedt / cd-nvm.sh
Created December 14, 2022 23:20
Run "nvm use" when changing into any directory
#!/bin/bash
# Run `nvm use` when changing into directory if the .nvmrc exists
function cd() {
builtin cd "$@"
if [[ -e .nvmrc ]]
then
nvm use
fi
@Fallenstedt
Fallenstedt / rest-in-peace.txt
Created October 27, 2021 00:30
Welcome to the legacy part of the app
_..--""---.
/ ".
` l
|'._ ,._ l/"\
| _J<__/.v._/
\( ,~._,,,,-)
`-\' \`,,j|
\_,____J
.--.__)--(__.--.
/ `-----..--'. j
@Fallenstedt
Fallenstedt / safebuffer.go
Created May 19, 2021 21:54 — forked from arkan/safebuffer.go
Golang: Buffer is a goroutine safe bytes.Buffer
package safebuffer
import (
"bytes"
"sync"
)
// Buffer is a goroutine safe bytes.Buffer
type Buffer struct {
buffer bytes.Buffer
@Fallenstedt
Fallenstedt / docker_export_postgre_table.sh
Last active May 17, 2021 04:02 — forked from gh0st026/docker_export_postgre_table.sh
Dump PostgreSQL Table in docker container as CSV file
CONTAINER="name"
DB="Db name"
TABLE="Table Name"
FILE="file.csv"
sudo docker exec -u postgres ${CONTAINER} psql -d ${DB} -c "COPY ${TABLE} TO STDOUT WITH CSV HEADER " > ${FILE}
# Copy csv to table
# sudo psql -h localhost -U root -d my_db -p 5432 -c "\COPY source_table TO '/home/user/source_table.csv' DELIMITER ',' CSV HEADER;"
@Fallenstedt
Fallenstedt / trafficlight.ino
Created April 18, 2021 00:11
traffic light
int switchState = 0;
// pins
const int BUTTON = 2;
const int RED_LED = 3;
const int YELLOW_LED = 4;
const int GREEN_LED = 5;
void setup() {