Skip to content

Instantly share code, notes, and snippets.

View Risyandi's full-sized avatar
🌴
Everyday is a vacation

Risyandi Risyandi

🌴
Everyday is a vacation
View GitHub Profile
@Risyandi
Risyandi / sortReverseNum.js
Last active April 15, 2021 07:56
reverse sorting value in array
let arr = [1,2,3,4,5,6];
let start = 0;
let end = arr.length - 1;
while (start < end) {
let temp = arr[start];
arr[start] = arr[end];
arr[end] = temp;
start++;
end--;
@Risyandi
Risyandi / convertAll.txt
Created April 18, 2021 15:30
convert all format to webp automate
for file in *.jpg; do cwebp -q 80 "$file" -o "${file%.jpg}.webp"; done
@Risyandi
Risyandi / convertSingle.txt
Created April 18, 2021 15:33
convert single format to webp
cwebp -preset picture -q 80 d:\source-images-original\1.jpg -o d:\source-images-result\1.webp
@Risyandi
Risyandi / clearReactSelect.js
Created July 28, 2021 03:46
line code for clear react select
import React, { useRef } from "react";
import Select from "react-select";
export default function App() {
const selectInputRef = useRef();
const onClear = () => {
selectInputRef.current.select.clearValue();
};
@Risyandi
Risyandi / createPdf.js
Created September 13, 2021 05:26
create pdf using pdfMake library
// library pdfMake
import pdfMake from "pdfmake/build/pdfmake";
import pdfFonts from "pdfmake/build/vfs_fonts";
pdfMake.vfs = pdfFonts.pdfMake.vfs;
// document definition
let docDefinition = {
content: [{
text: 'Report Goods Receive',
style: 'header'
@Risyandi
Risyandi / arrayMultidimension.js
Created September 13, 2021 05:30
convert array object, to array multidimension
let dataProps = [{
"id": 1,
"mat_doc": "5000001724",
"mat_doc_year": 2020,
"mat_doc_item": 1,
"ref_doc_num": "SJ1234567892",
"header_text": null,
"posting_date": "2020-08-09T17:00:00.000Z",
"doc_date": "2020-08-09T17:00:00.000Z",
"move_type": "101",
@Risyandi
Risyandi / getNumberTriple.js
Last active June 23, 2022 15:37
how to get number triple using looping for.
/**
* Risyandi - 2021
* how to create increment to triple number.
* first we have value from looping with initial duplicate 3.
* and the expected result like this :
* 111 222 333
* 111 222 333
* 111 222 333
* 444 555 666
* 444 555 666
@Risyandi
Risyandi / stringEncode.js
Created June 23, 2022 15:31
code challenge to encode a string
/**
* Risyandi - 2022
* how to create string to encode :
* first we have a data array as input
* for the example : [a, a, b, b, b, c, c]
* and for the expected result should be appear like this
* for the expected result : a2b3c2
*/
function stringEncode(input) {
function cekFunction(value) {
let length = value.split(" ").length;
let dimension = "";
if (length <= 2) {
dimension = value.split(" ").length > 1 ? value.split(" ")[0] : "";
} else {
dimension = value.split(" ").length > 1 ? value.split(" ")[1] : "";
}
let dimensionValue = dimension.split("x").length > 1 ? dimension.split("x") : [];
let volume = dimensionValue.length > 1 ? parseFloat(dimensionValue[0]) * parseFloat(dimensionValue[1]) * parseFloat(dimensionValue[2]) : 0;
@Risyandi
Risyandi / palindromeTwo.js
Created January 17, 2023 04:01
check have a palindrome
let string = "A man, a plan, a canal: Panama";
function palindromeTwo(alphabet) {
alphabet = alphabet.replace(/[^a-z0-9]/gi, "").toLowerCase();
let reverse = alphabet.split("").reverse().join("");
return alphabet === reverse;
}
palindromeTwo(string);