using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package safebuffer | |
import ( | |
"bytes" | |
"sync" | |
) | |
// Buffer is a goroutine safe bytes.Buffer | |
type Buffer struct { | |
buffer bytes.Buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import mrEmitter from '../helpers/mrEmitter' | |
export default class EmittingComponent extends React.Component { | |
handleClick = () => { | |
mrEmitter.emit('onSomeEvent', 'foo sends bar') | |
} | |
render() { |
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.
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.