Skip to content

Instantly share code, notes, and snippets.

View ekoeryanto's full-sized avatar

Eko Eryanto ekoeryanto

View GitHub Profile
@ekoeryanto
ekoeryanto / phonetic.spec.ts
Last active December 24, 2021 08:23
format phone number
import {Phonetic} from './phonetic';
describe('convert phone number to local number', () => {
const phonetic = new Phonetic('62');
test('international code with plus', () => {
expect(phonetic.localize('+628123')).toEqual('08123');
});
test('international code with plus and leading zero', () => {
expect(phonetic.localize('+6208123')).toEqual('08123');
@ekoeryanto
ekoeryanto / haproxy
Created May 18, 2021 18:58
Ubuntu Haproxy Init Script
#!/bin/sh
### BEGIN INIT INFO
# Provides: haproxy
# Required-Start: $local_fs $network $remote_fs $syslog $named
# Required-Stop: $local_fs $remote_fs $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: fast and reliable load balancing reverse proxy
# Description: This file should be used to start and stop haproxy.
### END INIT INFO
@ekoeryanto
ekoeryanto / example.js
Created November 28, 2019 14:38 — forked from numtel/example.js
Restart ZongJi gracefully on error
var ZongJi = require('zongji');
var RETRY_TIMEOUT = 4000;
function zongjiManager(dsn, options, onBinlog) {
var newInst = new ZongJi(dsn, options);
newInst.on('error', function(reason) {
newInst.removeListener('binlog', onBinlog);
setTimeout(function() {
// If multiple errors happened, a new instance may have already been created
@ekoeryanto
ekoeryanto / app.yaml
Created February 15, 2018 07:43
Google App Engine Static Website with Go Runtime
runtime: go
api_version: go1
threadsafe: yes
handlers:
- url: /.well-known/.*
script: _go_app
- url: /.*
script: _go_app
secure: always
@ekoeryanto
ekoeryanto / app.yaml
Created February 15, 2018 07:06
Google App Engine Static Website Route
handlers:
- url: /$
static_files: public/index.html
upload: public/index.html
# Handle folder urls by serving the index.html page inside.
- url: /(.*)/$
static_files: public/\1/index.html