Skip to content

Instantly share code, notes, and snippets.

View darkterminal's full-sized avatar

Imam Ali Mustofa darkterminal

View GitHub Profile
@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
@darkterminal
darkterminal / Javascript_toNumber.md
Created January 10, 2023 11:57 — forked from quant61/Javascript_toNumber.md
conversion to number in javascript

Some notes about conversion to number in javascript

javascript has lots of methods to convert any value to number

  • all methods could be divided into 2 groups: string and native methods
    • String methods are parseInt and parseFloat
    • Native mathods are Number and Math methods

all native methods behave the same way, sometimes with additional transform

@darkterminal
darkterminal / README.md
Created December 15, 2022 12:03 — forked from magnetikonline/README.md
NSSM - the Non-Sucking Service Manager cheatsheet.
const createLogger = (backgroundColor, color) => {
const logger = (message, ...args) => {
if (logger.enabled === false) {
return;
}
console.groupCollapsed(
`%c${message}`,
`background-color: ${backgroundColor}; color: ${color}; padding: 2px 4px;`,
...args
@darkterminal
darkterminal / gist:cbc0f6ff7b13d9ae17fe48f0ac9958bd
Created November 28, 2022 17:21 — forked from jacksonfdam/gist:3000275
Regular Expressions List
//Regular Expressions List
//Short Tutorial
\ // the escape character - used to find an instance of a metacharacter like a period, brackets, etc.
. // match any character except newline
x // match any instance of x
^x // match any character except x
[x] // match any instance of x in the bracketed range - [abxyz] will match any instance of a, b, x, y, or z
| // an OR operator - [x|y] will match an instance of x or y