Skip to content

Instantly share code, notes, and snippets.

View darkterminal's full-sized avatar
🕺
Dancing While Coding

Imam Ali Mustofa darkterminal

🕺
Dancing While Coding
View GitHub Profile
@darkterminal
darkterminal / peringatan-hatta-dan-fakta-hitler.md
Last active August 24, 2024 09:35
Peringatan Hatta dan Fakta Hitler - Moh Mahfud MD

image

Peringatan Hatta dan Fakta Hitler

Oleh: MOH MAHFUD MD

Bung Hatta berbicara banyak mengenai demokrasi, antara lain, melalui tulisan-tulisannya di majalah Daulat Ra’jat tahun 1931-1933, seperti dimuat dalam jilid 1 buku Karya Lengkap Bung Hatta (LP3ES, 1998).

Ketika Hatta menulis itu, 1931, Hitler di Jerman masih berjuang untuk meraih kekuasaan melalui proses demokrasi, yaitu memimpin partai dan ikut dalam pemilu. Namun, munculnya Hitler menjadi fakta bahwa yang dinyatakan oleh Bung Hatta itu benar.

@darkterminal
darkterminal / EXPLAIN.md
Last active August 20, 2024 18:46
Turso Database Token Generator for PHP

Explanation and Usage

This code will generate token for Local Development process with Turso. When you use turso-cli or sqld you need to generate database token to connect with your database remotely.

  • full_access_token - Used to connect with database with full access mode
  • read_only_token - Use to connect with database with read access only mode
  • public_key_pem and public_key_base64 - Use as decoding key in our server

Referring to Turso Docs - Local Development

It’s recommended to use environment variables for both url and authToken for a seamless developer experience.

@darkterminal
darkterminal / .env-example
Last active July 25, 2024 17:15
libSQL Daemon
# Database Path
SQLD_DB_PATH=data.sqld
# HTTP Listener Address
SQLD_HTTP_LISTEN_ADDR=127.0.0.1:8080
# Hrana Listener Address
SQLD_HRANA_LISTEN_ADDR=
# Admin HTTP API Address
@darkterminal
darkterminal / turso-php-installer.php
Last active June 17, 2024 10:05
Turso Client PHP - libSQL Extension for PHP (Script Installer)
<?php
$REPO = "https://raw.githubusercontent.com/tursodatabase/turso-client-php/main/release_metadata.json";
$OS = strtolower(php_uname('s'));
$ARCH = php_uname('m');
$HOME = trim(shell_exec('echo $HOME'));
$minimal_version = "8.3";
@darkterminal
darkterminal / command.php
Created April 7, 2024 16:42 — forked from mul14/command.php
Send signal to a process with PHP https://youtu.be/H2lp_jcfmu0
#!/usr/bin/env php
<?php
define('PID_PATH', '/tmp/myapp.pid');
define ('PID', (int) file_get_contents(PID_PATH));
if (empty($argv[1])) {
echo <<<INFO
@darkterminal
darkterminal / slime-mould-algorithm.js
Created July 14, 2023 05:38
Slime Mould Algorithm to find shortest path in a list of coordinates
function findShortestPath(coordinates, populationSize, maxIterations) {
// Initialize the positions of slime mould
const positions = [];
let bestFitness = Number.MAX_VALUE;
let bestPosition;
for (let i = 0; i < populationSize; i++) {
const position = coordinates.slice(); // Make a copy of the coordinates array
positions.push(position);
}
@darkterminal
darkterminal / 01-1-detail-research-methodology.md
Last active June 21, 2023 14:06
The Role of a Software Freestyle Engineer in Modern IT - This is imaginative journal written by me (Imam Ali Mustofa).

Research Methodology: The Role of a Software Freestyle Engineer in Modern IT

Introduction

This document provides an in-depth description of the research design, data collection methods, interview protocols, and case study procedures employed in the study titled "The Role of a Software Freestyle Engineer in Modern IT." It offers a comprehensive overview of the methodology used in the research, serving as a reference for researchers interested in replicating or expanding upon the study.

Research Design

The research followed a mixed-methods approach, combining qualitative and quantitative techniques to gather comprehensive insights into the role of a Software Freestyle Engineer. This approach allowed for a deeper understanding of the subject matter and the ability to triangulate findings from different data sources.

@darkterminal
darkterminal / harvesine.js
Created April 20, 2023 03:24
Calculate Distance from 2 Coordinates
function harvesine(pta, ptb) {
const [lat1, lon1] = pta.split(',')
const [lat2, lon2] = ptb.split(',')
// convert to radians
const rad1 = (lat1 * Math.PI) / 180;
const rad2 = (lat2 * Math.PI) / 180;
const dLat = ((lat2 - lat1) * Math.PI) / 180;
const dLon = ((lon2 - lon1) * Math.PI) / 180;
@darkterminal
darkterminal / exportService.js
Created February 8, 2023 21:23 — forked from davidcsejtei/exportService.js
Export from JavaScript to Excel (xlsx)
const xlsx = require('xlsx');
const path = require('path');
const exportExcel = (data, workSheetColumnNames, workSheetName, filePath) => {
const workBook = xlsx.utils.book_new();
const workSheetData = [
workSheetColumnNames,
... data
];
const workSheet = xlsx.utils.aoa_to_sheet(workSheetData);
@darkterminal
darkterminal / latency.txt
Created January 29, 2023 13:55 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD