Skip to content

Instantly share code, notes, and snippets.

View marcelaraujo's full-sized avatar

Marcel Araujo marcelaraujo

  • Lisbon/PT
View GitHub Profile
@marcelaraujo
marcelaraujo / CHANGELOG.md
Created October 11, 2017 20:32 — forked from dispix/CHANGELOG.md
OAUTH2 Authentication and token management with redux-saga

Revision 5

  • Fix error parsing

Revision 4

  • Add missing yield in the login function

Revision 3

@marcelaraujo
marcelaraujo / bash-cheatsheet.sh
Created January 23, 2018 15:35 — forked from LeCoupa/bash-cheatsheet.sh
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@marcelaraujo
marcelaraujo / Redux-saga module example.md
Created November 13, 2018 13:22 — forked from sbsrnt/Redux-saga module example.md
redux-saga module example

Gist contains example files for redux-saga user(GET) module. The structure of redux for included files in this gist:

redux
├── user                          # Module name
│   ├── __tests__                 # Directory for redux module tests
│   │   ├── actions.test.js       # Action tests
│   │   └── saga.test.js          # Saga tests
│   ├── actions.js                # Module actions (f/e.: fetchUserRequest, fetchUserSuccess)
│   ├── reducer.js                # Module reducer
@marcelaraujo
marcelaraujo / App.js
Created November 13, 2018 13:22
REACT & REDUX & ROUTER & HMR
// src/App.js
import React from 'react';
import {Provider} from 'react-redux';
import {ConnectedRouter} from 'react-router-redux';
import {history} from './history';
import {store} from './redux/store';
import {Root} from './components/Root';
There are multiple flattening strategies for observables:
With mergeMap (which has flatMap as an alias), received observables are subscribed to concurrently and their emitted values are flattened into the output stream.
With concatMap, received observables are queued and are subscribed to one after the other, as each completes. (concatMap is mergeMap with a concurrency of one.)
With switchMap, when an observable is received it's subscribed to and any subscription to a previously received observable is unsubscribed.
With exhaustMap, when an observable is received it's subscribed to unless there is a subscription to a previously received observable and that observable has not yet completed - in which case the received observable is ignored.
The concatAll, exhaust, mergeAll and switchAll operators for higher-order observables are implemented using the *Map operators.
---------------------------------------------------------------------------------------------------------------------
const TwitterPackage = require("twitter");
const DEBUG = process.env.debug;
const secret = {
consumer_key: process.env.consumer_key,
consumer_secret: process.env.consumer_secret,
access_token_key: process.env.access_token_key,
access_token_secret: process.env.access_token_secret
};
@marcelaraujo
marcelaraujo / create.sh
Last active March 17, 2020 17:35
Get the Service Account and Token. Generate the Kubeconfig
Get the Service Account and Token. Generate the Kubeconfig
# Update these to match your environment
SERVICE_ACCOUNT_NAME=spinnaker-service-account
CONTEXT=$(kubectl config current-context)
NAMESPACE=spinnaker
NEW_CONTEXT=spinnaker
KUBECONFIG_FILE="kubeconfig-sa"
@marcelaraujo
marcelaraujo / create.sh
Created March 17, 2020 17:35
Create custom kubeconfig file for each user
#!/bin/bash
if [[ -z "$1" ]] ;then
echo "usage: $0 <username>"
exit 1
fi
user=$1
kubectl create sa ${user}
secret=$(kubectl get sa ${user} -o json | jq -r .secrets[].name)
If you want to forward a non-k8s-managed port and have permission to stand up a new pod, you can run the alpine/socat image and port-forward to that:
kubectl run --restart=Never --image=alpine/socat TEMP_POD_NAME -- -d -d tcp-listen:PORT,fork,reuseaddr tcp-connect:HOSTNAME:PORT
kubectl wait --for=condition=Ready pod/TEMP_POD_NAME
kubectl port-forward pod/TEMP_POD_NAME LOCAL_PORT:PORT
Don't forget to bring the pod down once you're done.
kubectl delete pod/TEMP_POD_NAME --grace-period 1 --wait=false