Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# create docker engine config at /etc/docker/daemon.json
# to limit the size of container logs.
# usage (with curl):
# curl -s https://gist.githubusercontent.com/wzulfikar/e7740906110beaa90216f8f37320f5d8/raw/docker-daemon-log-opts.sh | sh
config_dir="/etc/docker"
config_file="$config_dir/daemon.json"
max_size=50m
@wzulfikar
wzulfikar / shamir-demo.js
Created October 23, 2018 08:22
shamir secret sharing demo in js
const secrets = require('secrets.js-grempe')
const shamir = {
create: (plainText, totalShares, threshold) => {
// convert the text into a hex string
var pwHex = secrets.str2hex(passphrase); // => hex string
// split into 2 shares with a threshold of 2.
// 1 share will be sent to backend and stored there
// and another share will be kept by the user.
@wzulfikar
wzulfikar / .drone.yml
Last active August 26, 2021 17:51
Drone CI slack template. more on drone.io + slack integration: http://plugins.drone.io/drone-plugins/drone-slack/
pipeline:
build:
image: alpine
commands:
- echo "do something :v"
slack:
image: plugins/slack
channel: dev__builds
webhook: https://hooks.slack.com/services/...
@wzulfikar
wzulfikar / par-demo.scala
Created November 19, 2017 04:25
Using parallel function and thread in Scala.
/**
* Using parallel function and thread in Scala.
*
* Run in scastie: https://scastie.scala-lang.org
*
*/
// Higher-order function that displays
// time elapsed to execute any given function
def timer (taskId : String, f: () => Unit) = {
@wzulfikar
wzulfikar / orderSummary.ts
Created November 14, 2017 18:08
Using TypeScript to create order summary.
/**
* Wed, 15 Nov 2017 at 0:56:13 MYT
* "Using TypeScript to create order summary."
*
* The purpose of this snippet is to demonstrate the
* use of TypeScript in our code.
* You can run this code online here:
* https://www.typescriptlang.org/play/
*
* PS:
@wzulfikar
wzulfikar / GetFbProfile.php
Created February 19, 2017 12:18
Get FB User Profile
<?php
/**
* fetch profile of given fb's user id. fields are optional.
*/
function getFbProfile($userId, array $fields = [])
{
$ACCESSS_TOKEN = 'YOUR_TOKEN_HERE';
$BASE_URL = 'https://graph.facebook.com/v2.6';
// fetch default fields if no fields passed
@wzulfikar
wzulfikar / Default.handlebars
Last active October 20, 2022 07:41
MacDown template that support mermaid diagram (http://knsv.github.io/mermaid/index.html). Save this snippet as `Default.handlebars` in `/Applications/MacDown.app/Contents/Resources/Templates/`
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
{{{ titleTag }}}
{{#each styleTags }}
@wzulfikar
wzulfikar / nginx-vhost-traccar
Created December 28, 2016 20:51
traccar config for nginx: proxy set for web & websocket. tested with cloudflare (https set to flexible). original: https://www.traccar.org/forums/topic/nginx-alias-configuration/
server {
listen 443;
listen 80;
server_name tracking.domain.com;
add_header Strict-Transport-Security max-age=63072000;
#client_max_body_size 200M;
# Security features
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
@wzulfikar
wzulfikar / Install composer on Amazon AMI running on EC2
Last active December 27, 2016 14:26 — forked from asugai/Install composer on Amazon AMI running on EC2
Install composer on Amazon AMI running on EC2
cd ~
sudo curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer
composer --version
@wzulfikar
wzulfikar / indonesia.sql
Last active November 29, 2016 16:55
Indonesia: provinces, districts, regencies, villages. Forked from github.com/edwardsamuel/Wilayah-Administratif-Indonesia
This file has been truncated, but you can view the full file.
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;