This file contains 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 generateRandomPassword(length) { | |
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_+=[]{}|;:,.<>? "; | |
let password = ""; | |
for (let i = 0; i < length; i++) { | |
const randomIndex = Math.floor(Math.random() * charset.length); | |
password += charset[randomIndex]; | |
} | |
return password; | |
} |
This file contains 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
var a1; | |
var a2 = []; | |
var a3 = {}; | |
var a4 = {x:undefined}; | |
var a5 = {x:'1'}; | |
console.log("a1:", a1?.x || 'error'); | |
console.log("a2:", a2?.x || 'error'); | |
console.log("a3:", a3?.x || 'error'); | |
console.log("a4:", a4?.x || 'error'); |
This file contains 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 toCamelCase(str){ | |
var regExp=/[-_]\w/ig; | |
return str.toLowerCase().replace(regExp,function(match){ | |
return match.charAt(1).toUpperCase(); | |
}); | |
} | |
function toCamelCaseList(arr) { | |
let result = []; | |
arr = arr.split("\n"); | |
for(var a of arr) { |
This file contains 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
<Style type="text/css"> | |
pre { display:none; background:red; color:white; font-weight:bold; padding:5px; width:850px; } | |
</Style> | |
<pre id="debugPre" style="display:none;"> | |
Your debugging HTML HERE | |
</pre> | |
<script type="text/javascript"> |
This file contains 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 printFormData(formId) { | |
const formEl = document.getElementById(formId); | |
const formData = new FormData(formEl); | |
const params = {}; | |
for(const [key, val] of formData.entries()) { | |
params[key] = val; | |
} |
This file contains 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
// Give dynamic rainbow colored borders to ALL the elements being found in query. Quite useful for testing CSS | |
function rainbow(query, styles) { | |
var colors = ['Red', 'Lime', 'Blue', 'Yellow', 'Cyan', 'Magenta', 'Silver', 'Gray', 'Maroon', 'Olive', 'Green', 'Purple', 'Teal', 'Navy'] | |
document.querySelectorAll(query).forEach(function(el) { | |
var rand = Math.floor(Math.random() * colors.length); | |
var color = colors[rand]; | |
el.style.border = '2px ridge ' + color; | |
if(styles != undefined) { | |
for(var [key, val] of Object.entries(styles)) { | |
el.style[key] = val; |
This file contains 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
package utils.logging; | |
import ch.qos.logback.classic.Logger; | |
import ch.qos.logback.classic.LoggerContext; | |
import ch.qos.logback.classic.encoder.PatternLayoutEncoder; | |
import ch.qos.logback.classic.spi.ILoggingEvent; | |
import ch.qos.logback.core.AppenderBase; | |
import org.slf4j.LoggerFactory; | |
public class CustomAppender extends AppenderBase<ILoggingEvent> { |
This file contains 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
<style> | |
@keyframes fadeout { | |
from { opacity:1; } | |
to { opacity:0; } | |
} | |
.toast { | |
position:fixed; left:0; bottom:0; padding:10px; | |
font-size:50px; color:red; font-weight:900; | |
animation: fadeout 1s ease-in forwards; |
This file contains 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
// if you put isHTML parameter true you'll get newline char as br HTML tag, or just get "\n" | |
function jsonBeautifier(jsonTxt, isHTML) { | |
let result = JSON.stringify(JSON.parse(jsonTxt), null, 4); | |
if(isHTML) result = result.replaceAll("\n", "<br />"); | |
return result; | |
} | |
This file contains 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
// String 채우기(padding) | |
// 사용법: getPaddedStr(원본문자열, 패딩이 포함된 총 길이, 채울 문자열, 채울 방향) | |
// ex) getPaddedStr("1135j", 10, "#", "left") = "#####1135j" | |
function getPaddedStr(strOrg, width, to, direction) { | |
if(!strOrg) return ""; | |
var strOrg = new String(strOrg), len = strOrg.length; | |
if(len >= width) return strOrg; | |
var strPad = new Array(width - len + 1).join(to); | |
return (direction == "left" |
NewerOlder