Skip to content

Instantly share code, notes, and snippets.

View dorman99's full-sized avatar
🎯
Focusing

Muhammad Hafizh Abdillah AR dorman99

🎯
Focusing
View GitHub Profile
@dorman99
dorman99 / nested_object.js
Created May 22, 2023 04:32
nested object handler
// "Given any JSON object. Please write a function to convert it to dot-notation object.
// {
// ""key"": {
// ""value1"": 100,
// ""value2"": 200,
// ""nested"": {
// ""inside"": true
// }
// }
package main
import (
"fmt"
"sort"
)
// var listInts []int = []int{9, 4, 5, 6, 7}
var Pages = [][]string{
@dorman99
dorman99 / CryptoJs & Golang
Created May 22, 2022 15:46 — forked from xsephiroth/CryptoJs & Golang
AES decrypt encrypt with CryptoJs & Golang
<template>
<div>
</div>
</template>
<script>
import CryptoJs from "crypto-js"
export default {
name: "",
data(){
@dorman99
dorman99 / psql_distance_calcualte.sql
Created October 20, 2021 17:39
method to generate amount of distance between 2 position on km
CREATE OR REPLACE FUNCTION distance(lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT) RETURNS FLOAT AS $$
DECLARE
x float = 111.12 * (lat2 - lat1);
y float = 111.12 * (lon2 - lon1) * cos(lat1 /92.215);
BEGIN
RETURN sqrt(x * x + y * y);
END
$$ LANGUAGE plpgsql; // km
@dorman99
dorman99 / list_of_6_factor.js
Created September 6, 2021 13:15
Find Factor Min 6
const list = [];
class Factor {
constructor(factor, total) {
this.factor = factor;
this.total = total || [];
this._findTotalFactor()
}
_findTotalFactor() {
for(let i = 1; i <= this.factor; i++) {
@dorman99
dorman99 / remove_duplicate_str.js
Created September 6, 2021 11:44
remove duplicate string
const fs = require("fs");
const file = fs.readFileSync("str.txt", "utf-8");
const removeDuplicateChar = (str) => {
return str.filter((v, idx) => {
const f = str.lastIndexOf(v);;
if (f && idx !== f) {
str.splice(f, 1);
}
return v;
});
@dorman99
dorman99 / index.js
Last active September 6, 2021 11:28
Find Best Profit Trading
const fs = require("fs");
const file = fs.readFileSync("sample.txt", "utf-8");
const data = file.split(" ");
const findProfit = (buyStats) => {
let bestBuyTime = 0;
let bestProfit = 0;
let currentHodl = 0;
let currentValue = 0;
let lastHodl = 0;
@dorman99
dorman99 / hasse.nb
Created January 20, 2019 14:33 — forked from Eckankar/hasse.nb
Generating Hasse diagrams in Mathematica
(* Combinatorica contains HasseDiagram,so we need to load it. *)
<<Combinatorica`;
(* The set the partial order operates on. *)
nums = {1, 2, 4, 7, 8, 14, 30};
(* Define our partial order. *)
pOrder[x_, y_] := Divisible[y, x];
(* Generate a directed graph from the partial order. *)
@dorman99
dorman99 / postjson.js
Created May 17, 2018 04:53 — forked from JacobHsu/postjson.js
#nodejs #npm - post json with node.js (npm request )
var request = require('request');
var options = {
uri: 'https://www.googleapis.com/urlshortener/v1/url',
method: 'POST',
json: {
"longUrl": "http://www.google.com/"
}
};
@dorman99
dorman99 / postjson.js
Created May 17, 2018 04:53 — forked from JacobHsu/postjson.js
#nodejs #npm - post json with node.js (npm request )
var request = require('request');
var options = {
uri: 'https://www.googleapis.com/urlshortener/v1/url',
method: 'POST',
json: {
"longUrl": "http://www.google.com/"
}
};