This file contains hidden or 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
| kubens() { | |
| kubectl config set-context $(kubectl config current-context) --namespace=$1 | |
| } | |
| kubectx() { | |
| kubectl config use-context $1 | |
| } |
This file contains hidden or 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 dns = require('dns'); | |
| const util = require('util'); | |
| const lookup = util.promisify(dns.lookup); | |
| let timeStart = new Date().getTime(); | |
| let times = 0; | |
| let minTime = Infinity; | |
| let maxTime = 0; | |
| let error = 0; |
This file contains hidden or 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
| #define _GNU_SOURCE | |
| #define _DARWIN_C_SOURCE | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <limits.h> | |
| #include <time.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netdb.h> |
This file contains hidden or 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
| function renderSuccessPage(req, res, renderProps, store, next, statusCode = 200) { | |
| setImmediate(() => { | |
| AWSXRay.captureFunc('SSR', () => { | |
| try { | |
| res.header('Content-Type', 'text/html; charset=utf-8') | |
| const content = { | |
| html: ReactDOMServer.renderToString(<Root store={store} renderProps={renderProps} />), | |
| store: store.getState().toJSON(), | |
| head: Helmet.rewind(), |
This file contains hidden or 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 default function startServer(handler) { | |
| AWSXRay.captureHTTPsGlobal(require('http')) | |
| const app = express() | |
| app.use(AWSXRay.express.openSegment('React')) | |
| // load other middlewares | |
| // load handlers | |
| app.use(AWSXRay.express.closeSegment()) |
This file contains hidden or 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
| function renderSuccessPage(req, res, renderProps, store, next, statusCode = 200) { | |
| setImmediate(() => { | |
| try { | |
| res.header('Content-Type', 'text/html; charset=utf-8') | |
| const content = { | |
| html: ReactDOMServer.renderToString(<Root store={store} renderProps={renderProps} />), | |
| store: store.getState().toJSON(), | |
| head: Helmet.rewind(), | |
| lang: getLanguage(req) |
This file contains hidden or 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 dns from 'dns' | |
| import AWSXRay from 'aws-xray-sdk' | |
| function patchDnsLookup() { | |
| const realLookup = dns.lookup | |
| dns.lookup = (hostname, ...args) => { | |
| if (hostname === process.env.AWS_XRAY_DAEMON_ADDRESS) { | |
| return realLookup(hostname, ...args) | |
| } | |
| AWSXRay.captureAsyncFunc('DNS Lookup', (subsegment) => { |
This file contains hidden or 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
| def split_icu(txt): | |
| import PyICU | |
| def is_tha(c): | |
| return ord(c) >= 0x0E00 and ord(c) <= 0x0E7F | |
| def merge(ans, tok): | |
| if is_tha(tok[0]) or len(ans[:-1]) == 0 or is_tha(ans[-1][0]): | |
| return ans + [tok] | |
| else: | |
| return ans[:-1] + [ans[-1] + tok] | |
| icu_txt = PyICU.UnicodeString(txt) |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Clickr</title> | |
| <link rel="stylesheet" href="./style.css"> | |
| </head> | |
| <body> | |
| <div id="title" class="title">Clickr</div> | |
| <div id="message">กดตรงไหนก็ได้เพิ่มเริ่มเล่น</div> |