Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<input type="text" id="searchText" placeholder="search" list="searchList" />
@gai00
gai00 / master.sh
Created January 25, 2019 09:48
k8s_practice
#!/bin/bash
# aws ubuntu 16.04/18.04 tested
# install
# Ref: https://kubernetes.io/docs/setup/independent/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl
sudo -s
apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
@gai00
gai00 / phpmyadmin.yaml
Created August 23, 2018 08:31
docker phpmyadmin compose(stack) example
version: "3.4"
services:
mariadb:
image: mariadb
networks:
- backend
environment:
MYSQL_ROOT_PASSWORD: test123
MYSQL_USER: test
@gai00
gai00 / run.php
Created June 20, 2018 03:34
reactphp promise async wrap
<?php
require_once(__DIR__ . '/vendor/autoload.php');
require_once(__DIR__ . '/wrap.php');
$loop = \React\EventLoop\Factory::create();
$result = wrap(function() {
$p1 = (new \React\Promise\Promise(function($resolve, $reject) {
global $loop;
echo("v1\n");
$loop->addTimer(1.0, function($timer) use($resolve, $temp) {
@gai00
gai00 / AudioManager.js
Last active May 1, 2018 12:20
Web Audio API
class AudioManager {
constructor(audioCtx) {
this.list = [];
this.audioCtx = audioCtx || new (window.AudioContext || window.webkitAudioContext)();
this.pool = {};
}
async load(url) {
let data = this.pool[url];
@gai00
gai00 / docker-compose.yaml
Created December 14, 2017 07:48
deploy on swarm with 2 nodes
version: "3.4"
services:
memcached:
image: memcached:alpine
networks:
- googlerank
deploy:
placement:
constraints:
@gai00
gai00 / index.js
Created September 18, 2017 10:20
koa routing example
// koa app ...
const domains = [
{
host: /c9/,
routes: [
{
path: /^\/user/,
method: 'get',
middleware: async (ctx, next) => {
// 處理 c9 GET /user
@gai00
gai00 / index.js
Last active September 18, 2017 09:51
nodejs is dynamic loading
// koa app ...
app.use(async (ctx, next) => {
const {url} = ctx.request;
if(url.match(/\/test/)) {
ctx.testDates = require('./test');
}
await next();
});
@gai00
gai00 / A.php
Created August 21, 2017 05:10
Phalcon nested model example
<?php
class A extend ModelBase {
public function beforeSave() {
$this->ar = (is_array($this->ar))? $this->ar: [];
foreach($this->ar as &$ar) {
if(!$ar->save()) {
$error = $ar->getMessages();
// 錯誤處理
              break;
@gai00
gai00 / configure_proxy_protocol.md
Created January 26, 2016 08:55 — forked from pablitoc/configure_proxy_protocol.md
Configuring Proxy Protocol

##Install AWS CLI Tools##

  1. Install AWS CLI Tools. You can also use the EC2 API Tool if you are more comfortable with them. But this write-up uses the EC2 CLI.
  2. Create a user via Amazon IAM or download the security accessID and securitykey you will need it to query Amazon CLI.
  3. using Terminal cd into .aws directory cd ~/.aws edit or create new file named config paste the following contents inside.
    `[default]`
    `aws_access_key_id = ACCESS_ID`
    `aws_secret_access_key = SECRET_ID`
    `output = json OR bson OR text`
    `region = PREFERRED_AWS_REGION`

Save the file as "config"