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 / getUrlInElementSaveToFile.js
Created June 29, 2024 15:28
get url in element and saved to text file
// class you can modify based on the target
// count length of element base on the target
let arrayValue = [];
let element = document.querySelectorAll('.project-cell.gl-w-11 a');
let length = document.querySelectorAll('.project-cell.gl-w-11 a').length;
for (let index = 0; index < length; index++) {
// get value of href in the element
// push value to array
let result = element[index].href;
arrayValue.push(result);
@Risyandi
Risyandi / timeConversion.go
Created April 5, 2024 13:50
time conversion from 12 hours to 24 hours.
package main
import (
"fmt"
"strings"
"strconv"
)
// Timeconversion is your solution code.
func Timeconversion (s string) string {
@Risyandi
Risyandi / eigerPalindrome.js
Created March 14, 2024 03:09
palindrome code test for eigerindo
// checking if the text is palindrome
function palindrome(string) {
let result = true;
let lengthString = string.length;
let indexJ = lengthString - 1;
for (let index = 0; index < lengthString / 2; index++) {
if (string[index] != string[indexJ]) {
@Risyandi
Risyandi / anilistCard.json
Created July 26, 2023 04:33
query graphQL example for API anilist
{
"query": "query($season:MediaSeason,$seasonYear:Int $nextSeason:MediaSeason,$nextYear:Int){trending:Page(page:1,perPage:6){media(sort:TRENDING_DESC,type:ANIME,isAdult:false){...media}}season:Page(page:1,perPage:6){media(season:$season,seasonYear:$seasonYear,sort:POPULARITY_DESC,type:ANIME,isAdult:false){...media}}nextSeason:Page(page:1,perPage:6){media(season:$nextSeason,seasonYear:$nextYear,sort:POPULARITY_DESC,type:ANIME,isAdult:false){...media}}popular:Page(page:1,perPage:6){media(sort:POPULARITY_DESC,type:ANIME,isAdult:false){...media}}top:Page(page:1,perPage:10){media(sort:SCORE_DESC,type:ANIME,isAdult:false){...media}}}fragment media on Media{id title{userPreferred}coverImage{extraLarge large color}startDate{year month day}endDate{year month day}bannerImage season seasonYear description type format status(version:2)episodes duration chapters volumes genres isAdult averageScore popularity mediaListEntry{id status}nextAiringEpisode{airingAt timeUntilAiring episode}studios(isMain:true){edges{isMain nod
@Risyandi
Risyandi / stringToSnakeCase.js
Created June 6, 2023 08:49
convert text string to tsnake case, and remove special character by condition.
function convertToSnakeCase(text) {
let snakeCaseText = "";
const specialChars = `!"#$%&'()*+,-./:;<=>?@[\\]^\`{|}~`;
for (let index = 0; index < text.length; index++) {
const char = text[index];
if (char === "_" || char === " ") {
snakeCaseText += "_"; // Preserve underscores and change spaces to underscores
} else if (!specialChars.includes(char)) {
@Risyandi
Risyandi / convertTime24to12hour.go
Created May 19, 2023 08:18
convert AM/PM 12 hour to 24 hour to time using golang
package main
import (
"bufio"
"fmt"
"io"
"os"
"strings"
"time"
)
@Risyandi
Risyandi / generateId.js
Last active May 5, 2023 08:50
generateID using javascript
function generateID() {
const date = new Date();
const day = ("0" + date.getDate()).slice(-2);
const month = ("0" + (date.getMonth() + 1)).slice(-2);
const year = date.getFullYear().toString().substr(-2);
const random = Math.random().toString(36).substring(2, 6).toUpperCase();
return `INV-DOL-${day}${month}${year}-${random}`;
}
const newID = generateID();
@Risyandi
Risyandi / pauseExecutionGoroutine.go
Created March 18, 2023 14:52
how to pause the execution of current go routine
// Go program to illustrate how
// to put a goroutine to sleep
package main
import (
"fmt"
"time"
)
// Here, the value of Sleep function is zero
@Risyandi
Risyandi / iframeFullPage.vue
Last active March 16, 2023 03:39
how to create page with contain iframe full page responsive and access others website in nuxtjs
<template>
<div class="iframe-container">
<iframe
class="iframe"
:src="iframeUrl"
allowfullscreen
scrolling="yes"
ref="iframe"
@load="handleIframeLoad"
></iframe>
// Set initial countdown time to 60 seconds
var countdown = 60;
// Update the timer display every second
setInterval(function() {
countdown--;
var seconds = countdown % 60;
var minutes = Math.floor(countdown / 60);
// Add leading zero to seconds if less than 10