Skip to content

Instantly share code, notes, and snippets.

View krisanalfa's full-sized avatar

Krisan Timur krisanalfa

  • Denpasar, Bali
View GitHub Profile
@krisanalfa
krisanalfa / rollup.ts
Created July 28, 2021 12:37
Simple Webpack Plugin
import { rollup } from 'rollup'
import { babel } from '@rollup/plugin-babel'
import nodeResolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
import replace from '@rollup/plugin-replace'
import { Compiler, compilation } from 'webpack'
import { Tapable } from 'tapable'
export class RollupPlugin implements Tapable.Plugin {
@krisanalfa
krisanalfa / covid-19.tl.js
Last active April 1, 2020 10:52
Simple script to get latest COVID-19 update in Timor-Leste
// Simple script to get latest COVID-19 update in Timor-Leste.
// Use it with:
// node ./covid-19.tl.js
const { request } = require('https');
const { promisify } = require('util');
const requestAsync = promisify((options, callback) => {
const req = request(options, res => {
if (!res.statusCode) {
@krisanalfa
krisanalfa / covid-19.id.ts
Last active March 23, 2020 05:15
COVID-19 in a shell :)
import { request, RequestOptions } from 'https';
import { promisify } from 'util';
interface IAuthResponse {
EmbedToken: string;
EmbedUrl: string;
ReportId: string;
}
interface IRequestOptions extends RequestOptions {
@krisanalfa
krisanalfa / bl-calculate-my-fav.js
Last active April 2, 2020 17:07
Bukalapak Javascript Toolkits
// Script ini berfungsi untuk menghitung semua "Barang Favorit" kalian. Steps:
// 1. Login
// 2. Buka halaman: https://www.bukalapak.com/bookmarks
// 3. Checklist barang-barang yang ingin kalian hitung
// 4. Buka JS console
// 5. Jalankan script di bawah
[...document.querySelectorAll(".c-inp--checkbox:checked")]
.map(el =>
parseInt(
// @ts-check
'use strict'
const { join } = require('path')
const { readFile } = require('fs')
const { promisify } = require('util')
const https = require('https')
const readFileAsync = promisify(readFile)
// @ts-check
const https = require('https')
/**
* @param {[number, number]} hrtime
*
* @returns {string}
*/
const parseHrtimeToSeconds = hrtime => (hrtime[0] + (hrtime[1] / 1e9)).toFixed(5)
@krisanalfa
krisanalfa / Dockerfile
Last active March 1, 2019 17:50
Docker with PHP 5.6 for common Laravel < 5.3 Application
FROM php:5.6-apache
# Install dependencies
RUN apt-get update \
&& apt-get install git libmcrypt-dev libzip-dev libmagickwand-dev --yes
# Install PHP extensions
RUN docker-php-ext-install \
mysqli \
pdo \
@krisanalfa
krisanalfa / multiple-php-versions-on-ubuntu-16.04.md
Created June 7, 2017 06:32 — forked from aaronbloomfield/multiple-php-versions-on-ubuntu-16.04.md
Running multiple PHP versions on Apache2 and Ubuntu 16.04

Setting up multiple apache2 instances on Ubuntu 16.04

PHP handling on apache is done via modules of one sort or another, and running multiple version is problematic on a single instance. The solution is to run two instances of apache on the same machine. This allows one instance to run PHP 7 (the default on 16.04), and another can run PHP 5. Since normal http/https is on ports 80 and 443, the second instance will run on ports 81 and 444. Since it is running on the same machine, all file system and database access is the exact same.

All the commands herein have to be run as root, or with sudo prefixed to the command.

  1. Read /usr/share/doc/apache2/README.multiple-instances

  2. Run sh ./setup-instance php5 from /usr/share/doc/apache2/examples, where php5 is the suffix for the second site; all commands for the second site will have that suffix. This will keep all of the same configuration for all sites on the new instance, including SSL certif

@krisanalfa
krisanalfa / update-all.py
Last active June 12, 2017 08:57
System Updater
#!/usr/bin/python
from os import devnull
from distutils import spawn
from pip import get_installed_distributions
from cement.core.foundation import CementApp
from subprocess import call, check_output, PIPE, Popen
from cement.core.controller import CementBaseController, expose
class BaseController(CementBaseController):
@krisanalfa
krisanalfa / .editorconfig
Last active June 7, 2017 07:47
Global EditorConfig
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Base
[*]
indent_style = space
indent_size = 2
end_of_line = lf