Skip to content

Instantly share code, notes, and snippets.

View adisetiawan's full-sized avatar
🏠
Working from home

Adi adisetiawan

🏠
Working from home
View GitHub Profile
const ALPHAPET = '234567abcdefghijklmnopqrstuvwxyz'
function encode (i) {
let s = ''
while (i) {
const c = i % 32
i = Math.floor(i / 32)
s = ALPHAPET.charAt(c) + s
}
return s
/**
* Wraps a function with caching functionality.
* Allows for caching of expensive functions like paginated API calls that rarely change.
*
* @param fn - The function to cache results from
* @param options - Optional configuration for the cache behavior
* @param options.maxAge - Maximum age of cached data in milliseconds
* @returns A function that returns the result of the function, either from cache or fresh execution
*
* @example
@adisetiawan
adisetiawan / ChatGPT Canvas HTML Renderer from Clipboard.url
Created October 10, 2024 06:25 — forked from rmtbb/ChatGPT Canvas HTML Renderer from Clipboard.url
Bookmarklet that lets you render a full HTML page with any included css and javascript that is currently copied to your clipboard. Also works for SVG code. Useful with ChatGPT Canvas
javascript:(function(){try{navigator.clipboard.readText().then(function(t){if(t){var e=window.open("","_blank","width=800,height=600");e.document.open(),e.document.write(t),e.document.close()}else alert("Clipboard is empty. Please copy some text to the clipboard first.")}).catch(function(t){console.error("Failed to read clipboard contents: ",t),alert("An error occurred while trying to access the clipboard. Please ensure your browser allows clipboard access.")})}catch(t){console.error("An error occurred:",t),alert("An error occurred while trying to open the new window with the clipboard content.")}})();//bookmarklet_title: HTML Preview from Clipboard
"""Async and await example using subprocesses
Note:
Requires Python 3.6.
"""
import sys
import time
import platform
import asyncio
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2020 Adi Setiawan <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
<!DOCTYPE html>
<html>
<body>
<!-- 1. The <iframe> (and video player) will replace this <div> tag. -->
<div id="player"></div>
<div>Current Time: <span id="time"></span></div>
<script>
// 2. This code loads the IFrame Player API code asynchronously.
var tag = document.createElement('script');
@adisetiawan
adisetiawan / gammu-install-osx.md
Created July 8, 2020 05:22 — forked from tomysmile/gammu-install-osx.md
Gammu: Install on OSX 10.11 with Wavecom Modem M1306B

Configuring Gammu for Mac OSX 10.11

Requirements

Step by step:

  • Type below command :

TERUSLAH BERSAHABAT SAMPAI WAKTUNYA PULANG

Ketika ada kesempatan, pergilah bersama teman teman lama. Berkumpul - kumpul, bukan sekadar makan, minum dan bersenang, senang tetapi ingat, Waktu hidup kita semakin singkat. Maka dari itu, bangunkanlah Persaudaraan

Mungkin lain waktu kita Tidak akan bertemu lagi.

Mungkin lain waktu kita sudah semakin Susah untuk berjalan.

Umur itu Seperti es batu, Dipakai atau tidak akan tetap mencair dan berakhir.

@adisetiawan
adisetiawan / answer.md
Last active June 11, 2020 02:10
interview answer

1

def commit(item) error = nil
  if action_1(item).success() && action_2(item).success() && action_3(item).success() && action_4(item).success() && action_5(item).success()
    # no error, all succeessful
  else
    error = "something went error" 
  end
 return error
<?php
// example code
$records = array(['satu' => 'satu', 'dua' => 'satu'],
['satu' => 'dua', 'dua' => 'dua'],
['satu' => 'tiga', 'dua' => 'tiga'],
['satu' => 'empat', 'dua' => 'empat'],
['satu' => 'lima', 'dua' => 'lima'],
['satu' => 'enam', 'dua' => 'enam'],
['satu' => 'tujuh', 'dua' => 'tujuh'],