Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Hello, mister!

Krisan Alfa Timur krisanalfa

:octocat:
Hello, mister!
View GitHub Profile
@krisanalfa
krisanalfa / rollup.ts
Created Jul 28, 2021
Simple Webpack Plugin
View rollup.ts
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 Apr 1, 2020
Simple script to get latest COVID-19 update in Timor-Leste
View covid-19.tl.js
// 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 Mar 23, 2020
COVID-19 in a shell :)
View covid-19.id.ts
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 Apr 2, 2020
Bukalapak Javascript Toolkits
View bl-calculate-my-fav.js
// 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(
View check-outdated-npm-packages.js
// @ts-check
'use strict'
const { join } = require('path')
const { readFile } = require('fs')
const { promisify } = require('util')
const https = require('https')
const readFileAsync = promisify(readFile)
View first-byte-time.js
// @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 Mar 1, 2019
Docker with PHP 5.6 for common Laravel < 5.3 Application
View Dockerfile
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 Jun 7, 2017 — forked from aaronbloomfield/multiple-php-versions-on-ubuntu-16.04.md
Running multiple PHP versions on Apache2 and Ubuntu 16.04
View multiple-php-versions-on-ubuntu-16.04.md

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 Jun 12, 2017
System Updater
View update-all.py
#!/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 Jun 7, 2017
Global EditorConfig
View .editorconfig
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Base
[*]
indent_style = space
indent_size = 2
end_of_line = lf