Skip to content

Instantly share code, notes, and snippets.

View NorikDavtian's full-sized avatar
🚢
Shipping

Norik Davtian NorikDavtian

🚢
Shipping
View GitHub Profile

JS Decorators Example for Redux Connect

In general, this would be used as follows:

class MyReactComponent extends React.Component {}

export default connect(mapStateToProps, mapDispatchToProps)(MyReactComponent);

However, because of how the decorator syntax works, this can be replaced with:

@connect(mapStateToProps, mapDispatchToProps)
$ docker system prune -a

WARNING! This will remove:
	- all stopped containers
	- all volumes not used by at least one container
	- all networks not used by at least one container
	- all images without at least one container associated to them
Are you sure you want to continue? [y/N] y
# git rebase --onto <branch name>~<first commit number to remove> <branch name>~<first commit to be kept> <branch name>
git rebase --onto repair~3 repair~1 repair
@NorikDavtian
NorikDavtian / jsonl-to-multiple-json-files.js
Created November 20, 2017 10:08
Small handy utility script to break large jsonl files to smaller json files.
// COUNT=3 INPUT=large_file.jsonl node jsonl-to-multiple-json-files.js
const fs = require('fs');
const readline = require('readline');
const COUNT = parseInt(process.env.COUNT); // Numer of lines to get from the large file
const input = fs.createReadStream(process.env.INPUT.toString()); // input .jsonl file
const rl = readline.createInterface({ input });
let counter = 0;
rl.on('line', (line) => {

Udacity K8s course notes

https://classroom.udacity.com/courses/ud615/lessons/7826112332/concepts/81473137730923

Download Go:

Note: Cloud Shell comes with an installed Go, but it's not the most recent version, so you should perform the steps below to install the latest Go and set GOPATH.

wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.6.2.linux-amd64.tar.gz
echo "export GOPATH=~/go" &gt;&gt; ~/.bashrc
# https://hub.docker.com/_/alpine/
docker pull alpine
# bind the volume to your container
docker run -v "$(pwd)/micro-service":/micro-service -it alpine
@NorikDavtian
NorikDavtian / random-string.js
Created July 22, 2018 07:35
Generate random string
/**
* From https://github.com/spotify/web-api-auth-examples/blob/master/authorization_code/app.js#L25-L33
* Generates a random string containing numbers and letters
* @param {number} length The length of the string
* @return {string} The generated string
*/
var generateRandomString = function(length) {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
FROM alpine
RUN apk update && apk upgrade
RUN apk add nodejs
WORKDIR /app
ADD . /app
ENTRYPOINT [ "node", "server.js" ]