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 / 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 / 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 / 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 / gist:af208cb7737ffe03048fa1620292de4a
Created January 2, 2018 01:11 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@Fallenstedt
Fallenstedt / ultimate-ut-cheat-sheet.md
Created July 10, 2017 01:29 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@Fallenstedt
Fallenstedt / EmittingComponent.js
Created April 6, 2017 03:43 — forked from puranjayjain/EmittingComponent.js
Using fbemitter-https://github.com/facebook/emitter/ (An event emitter) with React + ES6
import React from 'react'
import mrEmitter from '../helpers/mrEmitter'
export default class EmittingComponent extends React.Component {
handleClick = () => {
mrEmitter.emit('onSomeEvent', 'foo sends bar')
}
render() {
@Fallenstedt
Fallenstedt / fix-homebrew-npm.md
Created January 24, 2017 04:23 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.