Skip to content

Instantly share code, notes, and snippets.

View oscar60310's full-sized avatar
🐬

Ivan Tsai oscar60310

🐬
View GitHub Profile
@oscar60310
oscar60310 / echo.js
Last active November 16, 2021 15:51 — forked from bszwej/echo.js
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
const http = require('http');
const server = http.createServer();
server.on('request', (request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
@oscar60310
oscar60310 / function-and-object.ts
Created December 29, 2020 03:50
Property be a function and a object in same time
// ref https://stackoverflow.com/questions/12766528/build-a-function-object-with-properties-in-typescript
class Snadbox {
public test = Object.assign(() => this.runTest('RUN'), {
skip: () => this.runTest('test')
})
private runTest = (mode: string) => console.log(`Test in mode ${mode}`);
}
@oscar60310
oscar60310 / echo-server.yaml
Last active March 1, 2022 04:15
echo-server
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo-server
labels:
app: echo-server
spec:
replicas: 1
selector:
matchLabels:
apiVersion: apps/v1
kind: Deployment
metadata:
name: presto-worker
labels:
app: presto-worker
spec:
replicas: 1
selector:
matchLabels:
@oscar60310
oscar60310 / typescript-decorators-this.ts
Created December 18, 2020 03:46
Snippet about typescript decorators this binding
const authorize = () => (
target: any,
propertyKey: string,
) => {
let next: any;
const getter = () => next;
const setter = (old: any) => {
next = () => {
return old() +1;
#!/bin/sh
# Ubuntu 18.05
set -e
NODE_ADDRESS=${NODE_ADDRESS:-$(hostname --ip-address)}
KUBE_VERSION="1.16.15"
KUBE_PACAKGE_VERSION="1.16.15-00"
DOCKER_VERSION="18.06.3~ce~3-0~ubuntu"
echo "K8S API Addr: $NODE_ADDRESS"
const k8s = require("@kubernetes/client-node");
async function run() {
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const appsApi = kc.makeApiClient(k8s.AppsV1Api);
const watch = new k8s.Watch(kc);
const deploymentCache = new k8s.ListWatch(
`/apis/apps/v1/namespaces/default/deployments`,
watch,
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: test-frontend-1
spec:
scaleTargetRef:
apiVersion: apps/v1beta2
kind: Deployment
name: test-frontend-1
minReplicas: 1
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
var SERVERINFO = function () {
this.Varsion = 'beta-1.0.1';
this.UploadUrl = 'https://www.adventrip.net/TSSTAREA/Api.php';
this.ImageUrl = 'https:// ..... ';
/*
寫上其他全域設定
*/
}