Skip to content

Instantly share code, notes, and snippets.

View lelinhtinh's full-sized avatar
🤤
Slimming failure

Thành Thân Thiện lelinhtinh

🤤
Slimming failure
  • Da nang, Vietnam
  • 19:46 (UTC +07:00)
View GitHub Profile
@lelinhtinh
lelinhtinh / unicode.js
Created December 24, 2022 06:34 — forked from jchook/unicode.js
JavaScript UTF-8 Helpers
/**
* Convert a string to a unicode byte array
* @param {string} str
* @return {Array} of bytes
*/
export function strToUtf8Bytes(str) {
const utf8 = [];
for (let ii = 0; ii < str.length; ii++) {
let charCode = str.charCodeAt(ii);
if (charCode < 0x80) utf8.push(charCode);
#!/bin/bash
cd /tmp || exit
echo "Downloading Postman ..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
tar -xzf postman.tar.gz
rm postman.tar.gz
echo "Installing to opt..."
if [ -d "/opt/Postman" ];then
const cleanAccents = (str: string): string => {
str = str.replace(/à|á|||ã|â||||||ă|||||/g, 'a');
str = str.replace(/è|é||||ê||ế|||/g, 'e');
str = str.replace(/ì|í|||ĩ/g, 'i');
str = str.replace(/ò|ó|||õ|ô||||||ơ|||||/g, 'o');
str = str.replace(/ù|ú|||ũ|ư|||||/g, 'u');
str = str.replace(/|ý|||/g, 'y');
str = str.replace(/đ/g, 'd');
str = str.replace(/À|Á|||Ã|Â||||||Ă|||||/g, 'A');
str = str.replace(/È|É||||Ê|||||/g, 'E');
@lelinhtinh
lelinhtinh / androidPushNotification.php
Last active October 2, 2019 07:58 — forked from nelsbels/gist:9087748
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call androidPushNotification.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@lelinhtinh
lelinhtinh / grant-none-shim.js
Created September 8, 2019 08:19 — forked from arantius/grant-none-shim.js
Greasemonkey "@grant none" compatibility shim.
/*
The MIT License (MIT)
Copyright (c) 2014 Anthony Lieuallen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@lelinhtinh
lelinhtinh / README-Template.md
Created September 8, 2019 08:19 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

// if Navigation Timing is not supported, fallback to Date.naw() called on start (sufficient in many cases)
// Date.now is also polyfilled
(function(p){
if(!Date.now)
Date.now = function(){return +new Date};
if (!p.now){
var start = (p.timing && p.timing.navigationStart) || Date.now();
p.now = function now(){
return Date.now() - start;
@lelinhtinh
lelinhtinh / jquery-ajax-blob-arraybuffer.js
Created July 16, 2018 11:58 — forked from aaronk6/jquery-ajax-blob-arraybuffer.js
This fork supports request headers and returns text data if the request fails.
/**
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
*
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
* ajax transport, preventing the standard transport from hogging the request), and the * indicates that
* potentially any request with any dataType might want to use the transports provided herein.
*
* Remember to specify 'processData:false' in the ajax options when attempting to send a blob or arraybuffer -
@lelinhtinh
lelinhtinh / waitForKeyElements.js
Created September 12, 2017 13:07 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
@lelinhtinh
lelinhtinh / OpenWithSublimeText3.bat
Last active March 24, 2017 09:08 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f