Skip to content

Instantly share code, notes, and snippets.

View irfansofyana's full-sized avatar

Irfan Sofyana Putra irfansofyana

View GitHub Profile
@irfansofyana
irfansofyana / BigInt.cpp
Created August 4, 2019 03:53 — forked from ar-pa/BigInt.cpp
bignum class for C++
/*
######################################################################
####################### THE BIG INT ##########################
*/
const int base = 1000000000;
const int base_digits = 9;
struct bigint {
vector<int> a;
int sign;
/*<arpa>*/
@irfansofyana
irfansofyana / abstract_factory.java
Last active January 7, 2021 15:11
Example of non-executable code for creational design pattern
// Formally, the abstract factory pattern is defined as defining an interface to create families of related or dependent objects
// without specifying their concrete classes.
public interface IEngine {
void start();
}
public class F16Engine implements IEngine {
@Override
@irfansofyana
irfansofyana / init.vim
Last active January 9, 2022 14:05
neovim config
:set number
:set autoindent
:set tabstop=4
:set shiftwidth=4
:set smarttab
:set softtabstop=4
:set mouse=a
call plug#begin()
version: "3"
services:
zookeeper:
image: 'bitnami/zookeeper:latest'
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
image: 'bitnami/kafka:latest'
version: '3.7'
services :
postgres:
image: postgres:latest
volumes:
- infra-postgres:/var/lib/postgresql/data
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
@irfansofyana
irfansofyana / sync_gsheets_app_script.js
Last active November 4, 2022 03:02
Template code to sync values and formulas between two Google Sheets using App Script
function copySheets() {
sheetIDsToUpdate = [
// [sourceID, destID]
["source_google_sheets_id", "dest_google_sheets_id"]
]
for (let i = 0; i < sheetIDsToUpdate.length; i++) {
sourceID = sheetIDsToUpdate[i][0]
destID = sheetIDsToUpdate[i][0]
/**
* A Least Recently Used (LRU) cache with Time-to-Live (TTL) support. Items are kept in the cache until they either
* reach their TTL or the cache reaches its size and/or item limit. When the limit is exceeded, the cache evicts the
* item that was least recently accessed (based on the timestamp of access). Items are also automatically evicted if they
* are expired, as determined by the TTL.
* An item is considered accessed, and its last accessed timestamp is updated, whenever `has`, `get`, or `set` is called with its key.
*
* Implement the LRU cache provider here and use the lru-cache.test.ts to check your implementation.
* You're encouraged to add additional functions that make working with the cache easier for consumers.
*/