Skip to content

Instantly share code, notes, and snippets.

View rainstormza's full-sized avatar

Supakorn Thongtra rainstormza

View GitHub Profile
@rainstormza
rainstormza / axios.refresh_token.js
Created June 24, 2019 09:00 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@rainstormza
rainstormza / GoMgoSample-1.go
Created February 26, 2019 04:08 — forked from 345161974/GoMgoSample-1.go
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {
@rainstormza
rainstormza / Header.js
Created November 30, 2018 10:50
React Context API contextType example.
class Header extends Component {
// Define contextType as static class field.
static contextType = UserContext;
render() {
const user = this.context;
return user.isSignedIn ? (
<div>Hello {user.name}</div>
) : (
@rainstormza
rainstormza / accept.js
Created September 19, 2018 05:33 — forked from dsheiko/accept.js
/**
* Get round nested ternary operator
*
* <header>{
* accept()
* .when( a == 1, <h1>Case 1</h1>)
* .when( a == 2, <h1>Case 2</h1>)
* .otherwise( <h1>Case 3</h1>)
* .render()
* }</header>
@rainstormza
rainstormza / firebaseChannel.test.js
Created September 19, 2018 03:56 — forked from lourd/firebaseChannel.test.js
Example of making a channel in redux-saga with a firebase source and testing it with jest
import { eventChannel } from 'redux-saga'
function firebaseChannel(firebase, {
eventType = 'value',
returnSnapshot = false,
} = {}) {
return eventChannel(emit => {
const subscription = firebase.on(eventType, snapshot => {
emit(returnSnapshot ? { snapshot } : { value: snapshot.val() })
})
@rainstormza
rainstormza / customizing-vs-code.md
Created September 7, 2018 06:10 — forked from nickytonline/customizing-vs-code.md
Customizing VS Code for Two Fonts.

Customizing VS Code

I followed the instructions in this blog post Multiple Fonts: Alternative to Operator Mono in VSCode, but did not see any changes made to VS Code. After digging a bit, I discovered that all the CSS class names had changed. They’re now e.g. .mtk13, .mtk16 { … }.

Gotchas

  • Ensure it’s a file URL e.g. { "vscode_custom_css.imports": [ "file:///Users/Brian/Desktop/vscode-style.css" ] }
  • If you move the location of your file and update your user settings with the new location, you will need to disable and enable custom CSS cmd+shift+p.
  • Also, anytime you change the style in your custom CSS file, you need to disable, then re-enable the extension.

For reference

@rainstormza
rainstormza / docker-help.md
Created September 2, 2018 10:08 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@rainstormza
rainstormza / style.css
Created May 20, 2018 19:05 — forked from traumverloren/style.css
VSCode Customizations for Operator Mono, Fira Code, and Dark Candy Theme
/*
Instructions for MacOS:
- Install the fonts 'Operator Mono' & 'Fira Code'
- Install theme 'Dark Candy'
- Add the following config to the VS Code settings.json:
{
"editor.renderWhitespace": "all",
"editor.fontSize": 14,
@rainstormza
rainstormza / Router.js
Last active May 1, 2018 16:10 — forked from dabit3/Router.js
Router implementation for React Authentication
import React from 'react'
import {
withRouter,
Switch,
Route,
Redirect,
BrowserRouter as Router
} from 'react-router-dom'
import { Auth } from 'aws-amplify'
@rainstormza
rainstormza / uniq.js
Created September 22, 2017 08:29 — forked from telekosmos/uniq.js
Remove duplicates from js array (ES5/ES6)
var uniqueArray = function(arrArg) {
return arrArg.filter(function(elem, pos,arr) {
return arr.indexOf(elem) == pos;
});
};
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});