Skip to content

Instantly share code, notes, and snippets.

@M4R14
M4R14 / puppeteer-jest.js
Last active September 6, 2017 09:38
puppeteer-jest.js async/await Callback
const puppeteer = require('puppeteer');
const Chrome = async ({ STEP }) => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await STEP(browser, page);
browser.close();
}
version: '3.1'
services:
web:
build: ./www
volumes:
- ./www:/var/www/app
ports:
- 8000:8000
links:
- db
@M4R14
M4R14 / Dockerfile
Last active September 10, 2017 08:28
FROM ubuntu:16.04
WORKDIR /var/www/app
# Update
RUN apt-get update
# base tool
RUN apt-get install -y curl python git unzip iputils-ping
@M4R14
M4R14 / index.js
Last active September 12, 2017 04:04
Long Polling JS
const fs = require('fs');
console.reset = function () {
return process.stdout.write('\033c');
}
const read_todo = () => {
return new Promise((res, rej)=>{
fs.readFile('./todo.json', 'utf8', (err, data) => {
if (err) throw rej(err);
@M4R14
M4R14 / long-polling-with-api.html
Created September 12, 2017 05:05
Long polling with Api
<div >
time: <span id="time"></span> ms, counter: <span id="counter"></span>
</div>
<h4>วันหยุด mahidol</h4>
<ul id="todo-list" style="list-style-type: decimal;">
</ul>
<script>
var elem = {
list : document.getElementById("todo-list"),
@M4R14
M4R14 / app.js
Created September 23, 2017 09:15
const SshPipe = require('./ssh-pipe.js');
( async ( )=>{
const production = new SshPipe({
connent: {
host: '******',
user: '****',
pass: '****',
agent: process.env.SSH_AUTH_SOCK,
agentForward: true,
baseDir: '/home/var/www'
@M4R14
M4R14 / .js
Created September 28, 2017 23:42
auto render
class Render{
constructor({ state, render}){
this.state = state
this.log = []
this.step = render || (() => {})
this.render()
}
setState(input){
@M4R14
M4R14 / example.php
Last active October 2, 2017 02:16
จัดกลุ่มข้อมูล
<?php
$data = [
(object) [
"id" => 1,
"number" => 0,
"text" => "000000000"
],
(object) [
"id" => 1,
"number" => 1,
// Controller.php
$breadcrumb = [
  [ "label" => $page_title, "path" => "/$path" ],
  [ "label" => $txt_manage, "path" => null ],
];

// view.blade.php
@section('page-title')
 @include('breadcrumb', ['breadcrumb' =&gt; $breadcrumb])
@M4R14
M4R14 / alpine.Dockerfile
Created February 3, 2018 07:00
Dockerfile: for laravel project alpine OS, PHP7, composer, node8, yarn
FROM alpine:3.7
RUN apk update && apk add build-base
# php7
RUN apk add \
php7 \
php7-json \
php7-phar \
php7-iconv \