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 { shuffle } from 'lodash' | |
export interface Box { | |
/** | |
* Value written on top of the Box | |
*/ | |
boxIndex: number | |
/** | |
* Value written inside the Box |
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
export type InstanceCreator<S, T> = (others: Readonly<S>) => T | |
export type InstanceCreators<S> = { | |
[K in keyof S]: InstanceCreator<S, S[K]> | |
} | |
/** | |
* Singleton implementation provider | |
* | |
* Example Usage: |
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
const assertThaiId = (thaiId: string): boolean => { | |
const m = thaiId.match(/(\d{12})(\d)/) | |
if (!m) { | |
console.warn('Bad input from user, invalid thaiId=', thaiId) | |
throw new Error('thai-id-must-be-13-digits') | |
} | |
const digits = m[1].split(''); | |
const sum = digits.reduce((total: number, digit: string, i: number) => { | |
return total + (13 - i) * +digit; | |
}, 0) |
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
const buildTimeConfig = { | |
base: process.env.APP_BASE_PATH || '/', | |
} | |
export default { | |
env: { | |
...buildTimeConfig | |
}, | |
serverMiddleware: [ | |
{ |
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 { createDecipheriv, randomBytes, CipherGCM, HexBase64BinaryEncoding, createCipheriv, Decipher, pbkdf2Sync } from 'crypto' | |
const gcmTagSize = 16 | |
const nonceSize = 12 | |
export default class Tunnel { | |
private getDecipher: (iv: Buffer, authTag: Buffer) => Decipher | |
private getCipher: (iv: Buffer) => CipherGCM |
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
#!/bin/sh | |
# Before start make sure you have created a CSR and issued a CRT files from Server. | |
# | |
# openssl req -new -newkey rsa:2048 -nodes -keyout private.key -out ${1}.csr | |
# | |
# unzip ${1}.zip | |
# cat ${1}.crt > ${1}.pem | |
# cat ${1}.ca-bundle >> ${1}.pem |
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 * as React from 'react' | |
import { RootState } from '../store' | |
import { connect } from 'react-redux' | |
import { login } from '../store/session/actions' | |
import { AccessToken } from '../store/session/reducers' | |
import { ThunkDispatch } from 'redux-thunk' | |
interface State { | |
} |
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 * as React from 'react' | |
import { BrowserRouter as Router, Route } from 'react-router-dom' | |
import { Provider } from 'react-redux' | |
import store from './store' | |
import Dashboard from './pages/Dashboard' | |
import Login from './pages/Login' | |
// Style | |
import './App.css'; |
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
// store/session/actions.ts | |
import { AnyAction } from 'redux'; | |
export interface SetAction { | |
type: 'SET' | |
accessToken: string | |
} | |
export interface Fetching { |
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
const rgx = /(?:https?:)?\/{2}(?:www\.)?youtu\.?be(?:\/|\.com\/watch\?v\=|\.com\/v\/|\.com\/embed\/)?([\w-]*)[?&]?.*/ | |
// Support: | |
// - Simple = https://www.youtube.com/watch?v=I2aC297uaZ4&t=120 | |
// - Short = https://youtube.com/embed/_fIABbpAsjQ?t=120 | |
// - Shorter = https://youtu.be/I2aC297uaZ4?t=9 | |
// - Even Shorter = //youtu.be/I2aC297uaZ4?t=9 | |
// TEST: | |
[ |
NewerOlder