Skip to content

Instantly share code, notes, and snippets.

View armedi's full-sized avatar

Armedi armedi

View GitHub Profile
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
uid: prometheus
access: proxy
orgId: 1
url: http://prometheus:9090
basicAuth: false
@armedi
armedi / setPathRequired.ts
Created May 7, 2021 05:42
set value for given object path with TypeScript
import { CamelCasedPropertiesDeep, Merge } from 'type-fest'
import { DeepRequired, MarkRequired } from 'ts-essentials'
// https://www.typescriptlang.org/play?ts=4.1.0-pr-40336-88&ssl=25&ssc=78&pln=1&pc=1#code/FAFwngDgpgBACgQxACwJIFsIBsA8AVAGhgGkowYoAPEKAOwBMBnGAazIHsAzGPAPhgC8wGCTIVqdJjEYgATgEtaAc2EwA-DwDapMAF1xNBswBKUAMbtZ9HDIXKiCWmF6qRGgD4wABgBIA3joAvgB0-ogoGNj42mS6RACilGZYAK70UDhsYFxaOnGsHNyOYJq6vPwAZNJyikqBXq4iMJ6+AWQh-onJaRlZOXgxekR9RU6lldV2dQ1NMABcMLRQAG5QsqoLS6uyANzAoJCw4WiYWABM+PwC8EgnUYQF2dx8zY-9ewfQNyiXgt9351+VEMUlstVeIx46n+kUBLwWkLwH3AX2OADUEKkMg84AZJMxjpcrqpccD8d5-IpOGtRGAOn4qTTTDJ6qoNDo8UY3s9GhpmSBOVJCQM8i5Zm5-hisdE8kR+WLxZsVmtGkrtht4ILmIjeVo4LpVYtlbt9ulkghZLBOClaGYQPJ2LQYEooCB8ERSRIucLygAKdgAIwAVgsHhBbgs4ABKSO3KUpbEe3gfCy0GQwQNB8wC65+VSceSyGQAOQQ6CgCwARAAReRQJTsSsEVRYBAlssVmCVgASCAAXk3VAgXQsAMwABmbIggsnYWbtjAWmkafkWHarpgQLHkICbMFTNQDKRAlkXMAAbAAOGCBKdNVe0dddgDCjpkSCge4PCiPJ6LCwARjOG87wNQIYDbfc3xAD4XRAf1g2zIhKxnOdzErKMdiAA
type PathImpl<T, Key extends keyof T> = Key extends string
? T[Key] e
@armedi
armedi / workers-kv.ts
Last active December 17, 2020 08:49
workers-kv
/* ... */
declare const REDIRECTS: KVNamespace
interface Redirect {
to: string
from: string
}
const save = async (data: Redirect): Promise<void> => {
@armedi
armedi / index.html
Created October 31, 2020 05:12
rescript-blurhash example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Using rescript-blurhash</title>
<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />
<link
rel="preload"
as="style"
@armedi
armedi / shorten
Last active September 20, 2020 04:23
kuy.sh
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const hash = require('string-hash');
let [url, shortUrl] = process.argv.slice(2);
if (!url) {
@armedi
armedi / app.js
Last active September 13, 2020 04:41
express-jsx
app.get('/', (req, res) => {
res.render('home', { ip: req.ip });
});
@armedi
armedi / using_masa.js
Last active January 3, 2022 07:35
Menggunakan library masa untuk memformat tanggal ke bahasa Indonesia
import { masa } from 'masa';
masa(new Date('2020-08-17')).format('[hari] dddd, [tanggal] D MMMM YYYY');
// hari Senin, tanggal 17 Agustus 2020