Skip to content

Instantly share code, notes, and snippets.

View ducdhm's full-sized avatar
:electron:
Keep Moving Forward

Duc Doan (Bobby) ducdhm

:electron:
Keep Moving Forward
  • Ha Noi, Vietnam
View GitHub Profile
@ducdhm
ducdhm / index.html
Created September 27, 2021 09:24
console.log to HTML
<style>
#log {
position: fixed;
z-index: 9999999999999999999999;
bottom: 5px;
right: 5px;
left: 5px;
padding: 10px;
box-shadow: 0 0 3px rgba(0, 0,0, .2);
background: #333;
@ducdhm
ducdhm / removeTone.js
Created October 5, 2019 01:56
Remove Vietnamese tones
function removeTone(str, isCaseSensitive = false) {
let formatted = isCaseSensitive ? str : str.toLowerCase();
formatted = formatted.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, 'a');
formatted = formatted.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, 'e');
formatted = formatted.replace(/ì|í|ị|ỉ|ĩ/g, 'i');
formatted = formatted.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, 'o');
formatted = formatted.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, 'u');
formatted = formatted.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, 'y');
formatted = formatted.replace(/đ/g, 'd');
@Bambina-zz
Bambina-zz / index.js
Created April 30, 2019 08:19
A cloud function which sends data notification to all users stored in Firestore.
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
// Import the Firebase SDK for Google Cloud Functions.
STEP 1
Perform full installation of C++ Build Tools 2015 (from: https://blogs.msdn.microsoft.com/vcblog/2016/03/31/announcing-the-official-release-of-the-visual-c-build-tools-2015/)
(I say full install because this is what I did, however I don't claim that the full install is necessary)
Note: this may take a while as the full program is over 4GB
STEP 2
Install Python 2.7.11 (from: https://www.python.org/)
Note: during installation select the "add to PATH" option (which is not selected by default)
STEP 3
@artturik
artturik / translate.html
Created April 4, 2016 09:09
Forced Google Translate (also can be used as April Fools Day joke)
<!--
This code will translate page contents automatically (without user input)
Settings located at line 9, current script will translate english to estonian
-->
<style>#google_translate_element,.skiptranslate{display:none;}body{top:0!important;}</style>
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'et', autoDisplay: false}, 'google_translate_element');
var a = document.querySelector("#google_translate_element select");
@xPaw
xPaw / steam_quick_queue.user.js
Last active June 21, 2024 16:13
⚠ This script has been integrated into SteamDB browser extension!
// ==UserScript==
// @name Steam Queue Auto Discoverer
// @description Discover the Steam queue three times to get the sale cards
// @version 2.3.0
// @namespace https://gist.github.com/xPaw/73f8ae2031b4e528abf7
// @icon https://store.steampowered.com/favicon.ico
// @match https://store.steampowered.com/explore*
// @grant none
// ==/UserScript==
@ducdhm
ducdhm / generatePasswordRegex.js
Last active August 29, 2015 13:59
Generate password regexp for validating purpose
/**
* Generate password regex
* @method generatePasswordRegex
* @param {Number} min Minimum length of password
* @param {Number} max Maximum length of password
* @param {String} specialCharacter List of special characters
* @param {Number} specialLength Number of required special character in password
* @param {Number} uppercaseLength Number of required uppercase character in password
* @param {Number} numberLength Number of digit character in password *
*/
@ducdhm
ducdhm / example.js
Last active August 29, 2015 13:56
Get value when press key down with keydown2
$('#query').keydown2(function () {
console.log($(this).val());
});
@ducdhm
ducdhm / addNumber.js
Last active September 27, 2016 03:19
Add multiple floats as well as numbers
/**
* Bob Math utilities
* @author: ducdhm
* @created: Tue, Feb 11th, 2014 (GTM+7)
*/
(function(Math) {
/**
* Find the number of decimal places
* @method findDec
* @param {Float|Number} dec
@jcppkkk
jcppkkk / OpenWithSublime.bat
Last active June 25, 2023 22:07 — forked from FoxColdMetal/OpenWithSublimeText.bat
[[[ Move to https://github.com/jcppkkk/OpenWithSublime !!! ]]] Add context menu to allow user open file or folder with Sublime as User (or as Admin).
@echo off
:: Path to Sublime Text installation dir.
SET stPath=%~dp0sublime_text.exe
SET stPathOnly=%~dp0
:: Key name for the registry entries.
SET UserEntry=Sublime Text
SET AdminEntry=Sublime Text As Admin
:: Context menu texts.
SET "UserMenuText=Open with Sublime(&-)"
SET "AdminMenuText=Open with Sublime As Admin(&+)"