Skip to content

Instantly share code, notes, and snippets.

View LI-NA's full-sized avatar

Kwon Hyungjoo LI-NA

View GitHub Profile
@LI-NA
LI-NA / replaceAll.js
Created May 16, 2019 05:41
Javascript single line replace all function using RegExp.
/**
* Replace every string to string from string. lol
* @param {string} target target string
* @param {string} from search value
* @param {string} to replace value
*/
const replaceAll = (target, from, to) => target.replace(new RegExp(from.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), to)
// it is same as this.
@LI-NA
LI-NA / convertColor.js
Last active April 4, 2019 07:34
How to convert HEX. RGB, RGBA... etc
// One line HEX to RGB. Super fast and human-readable (maybe?)
let hex = "#aabbcc";
console.log("Simple one line HEX to RGB", "rgb(" + ['0x' + hex[1] + hex[2] | 0, '0x' + hex[3] + hex[4] | 0, '0x' + hex[5] + hex[6] | 0].join() + ")");
// It can be make like this to support RGBA.
let hex1 = "#aabbccdd";
console.log("Simple one line HEX to RGB", "rgba(" + ['0x' + hex1[1] + hex1[2] | 0, '0x' + hex1[3] + hex1[4] | 0, '0x' + hex1[5] + hex1[6] | 0, (hex1[7] ? ('0x' + hex1[7] + hex1[8] | 0) / 255 : 0)].join() + ")");
// To make function... (support #abc, #aabbcc, #aabbccdd)
const hexToRgb = function (hex) {
@LI-NA
LI-NA / CloudFlareDynDns.ps1
Created April 2, 2019 14:33
Cloudflare DDNS using Powershell 6 (Fix to using Tls1.2). From https://github.com/potatoqualitee/modules/tree/master/CloudFlareDynDns
#Requires -Version 3
Function Update-CloudFlareDynamicDns
{
<#
.SYNOPSIS
Updates specified CloudFlare DNS hostname to the current connection's external IP address using CloudFlare API v4
https://api.cloudflare.com/
.DESCRIPTION
This module is useful for homelabs. Remember how DynDns used to dynamically update your IP address for free? The functionality provided by this module is similar but updates CloudFlare hosted domains. CloudFlare is free and awesome, and I recommend it, if even for its simplified DNS management and free HTTPS.
@LI-NA
LI-NA / mega.js
Last active May 9, 2024 10:16
MEGA Chrome extension was HACKED. Please remove it NOW!
// This is Chrome Mega extension script that hacked!!!
// Version is 3.39.4_0.
// You can check it from your comptuer too.
// %AppData%\Local\Google\Chrome\User Data\Default\Extensions\bigefpfhnfcobdlfbedofhhaibnlghod\3.39.4_0
// Original mega.js is here. https://github.com/meganz/chrome-extension/blob/master/mega.js
function getParameterByName(name, data) {
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), results = regex.exec(data);
if (!results) return '';