This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Map string values char by char to array of byte | |
'Hello'.bytes() | |
// Map string values char by char to array of string | |
'Hello'.bytes().map(it.str()) | |
// or | |
'Hello'.split('') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
How to capitalize string in V programming language | |
**/ | |
fn capitalize(str string) string { | |
mut words := str.split(' ') | |
for i, word in words { | |
if word.len == 0 { continue } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ejs = require('ejs') | |
const puppeteer = require('puppeteer') | |
const fs = require('fs') | |
const { Buffer } = require('buffer') | |
const { PDFDocument } = require('pdf-lib') | |
async function createPDF({ template, data, output, title = 'Laporan', format = 'A4' }) { | |
const content = ejs.render(fs.readFileSync(template).toString(), data) | |
const browser = await puppeteer.launch({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bulk rename files. | |
rename 's/\.txt$/.text/' *.txt | |
rename 's/\.old$/.new/' *.old |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
These media querie breakpoints is inspired from tailwind css | |
https://tailwindcss.com/docs/breakpoints | |
/* | |
/* 0px - 320px */ | |
/* extra small: 320px - 640px */ | |
@media (min-width: 320px) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
How to add search query to url in JavaScript | |
By. Don Alfons Nisnoni <[email protected]> | |
**/ | |
function addSearchQuery(baseURL, searchQueryObj) { | |
const url = new URL(baseURL); | |
for (const key of Object.keys(searchQueryObj)) { |
Use sshfs to mount an AWS EC2 folder using PEM file
sshfs -o "IdentityFile=path/to/file.pem" ubuntu@EC2_HOST:/path/to/dir /path/to/mount/point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomDate() { | |
// Start from 01 Jan 2010 | |
const start = new Date(2010, 1, 1); | |
// End with current date | |
const end = new Date(); | |
const randomDate = new Date( | |
start.getTime() + Math.random() * (end.getTime() - start.getTime()) | |
); | |
return randomDate.toISOString().slice(0, 10); | |
} |
OlderNewer