Skip to content

Instantly share code, notes, and snippets.

@dennbagas
dennbagas / pv-pvc-deployment.yaml
Last active February 25, 2022 15:36
Golang in container Hot Reload
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-app-pv-volume
namespace: my-namespace
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
@dennbagas
dennbagas / role-rolebinding-sa.yaml
Created February 25, 2022 15:27
Golang in container Hot Reload
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-app-sa
namespace: my-namespace
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
@dennbagas
dennbagas / Dockerfile
Last active February 25, 2022 15:17
Golang in container Hot Reload
FROM golang:alpine
WORKDIR /go/src/app
COPY . .
RUN go mod download -x
RUN go get github.com/githubnemo/CompileDaemon
ENTRYPOINT CompileDaemon --build="go build -o tmp/main" --command="./tmp/main"
@dennbagas
dennbagas / vue.json
Created July 24, 2021 07:33
Nuxt VSCode Snippet
{
"Nuxt Class Component": {
"prefix": "vue-component-class-ts",
"body": [
"<template>",
" <div></div>",
"</template>",
"",
"<script lang=\"ts\">",
"import { Component, Vue } from 'vue-property-decorator'",
@dennbagas
dennbagas / delete-duplicate-postgres.sql
Created January 20, 2021 05:13
Query to delete duplicate data by a column and keep the last one
DELETE FROM user_devices WHERE ctid IN (
SELECT ctid FROM (
SELECT ctid, ROW_NUMBER() OVER (PARTITION BY device_id ORDER BY id DESC) AS rn
FROM user_devices
) t
WHERE rn > 1)
@dennbagas
dennbagas / build.yml
Last active November 25, 2020 07:07
BMKG Weather API
name: Netlify Builds
on:
schedule:
- cron: "00 22 */3 * *"
jobs:
build:
runs-on: ubuntu-latest
@dennbagas
dennbagas / netlify.toml
Created October 20, 2020 17:43
BMKG Weather API
[build]
command = "npm install && npm run collect:data"
functions = "./functions"
[dev]
functions = "./functions"
@dennbagas
dennbagas / weather.js
Created October 20, 2020 17:30
BMKG Weather API
'use strict';
const express = require('express');
const serverless = require('serverless-http');
const bodyParser = require('body-parser');
const request = require("request-promise");
const app = express();
const router = express.Router();
router.get('/', async (req, res) => {
@dennbagas
dennbagas / resource.js
Created October 20, 2020 17:26
BMKG Weather API
const fs = require("fs");
const bmkg_data = require("./bmkg_data");
const xml = require("xml2js");
const request = require("request");
const async = require("async");
const path = require('path');
let dataArray = [];
console.log('getting weather data...');
@dennbagas
dennbagas / postgresql-update-multiple.ts
Created June 29, 2020 15:24
Postgres UPDATE multiple Row and Value Node.js
type UpdateTuple = [primary, value_a, value_b];
async updateMultiple(data: UpdateTuple[]) {
return this.manager.transaction(async (transactionalManager) => {
if (data.length === 0) {
throw 'data cannot be empty';
}
// generate parameter index for pgsql query
const paramsIndex = data.map((v, i) => {