Skip to content

Instantly share code, notes, and snippets.

View tranchausky's full-sized avatar
🏹
done

chautran tranchausky

🏹
done
  • Ha Noi, Nghe An
View GitHub Profile
@tranchausky
tranchausky / hardware-esp8266.ino
Last active July 29, 2024 17:46
esp32/esp8266 get hardware infor (RAM/ROM)
#include <WiFi.h>
//#include <ESP8266WiFi.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
printHardwareInfo();
printBoardName();
printMacIp();
@rvrsh3ll
rvrsh3ll / windows-keys.md
Created February 18, 2024 22:44
Windows Product Keys

NOTE

These are NOT product / license keys that are valid for Windows activation.
These keys only select the edition of Windows to install during setup, but they do not activate or license the installation.

Index

https://stackoverflow.com/a/73744343/3633498
<br/>
<br/>
<br/>
<input type="file" id="inputImg">
<img src="" id="pic1">
<script>
async function compressImage(blobImg, percent) {
@episage
episage / fastest_for.js
Last active August 26, 2024 15:36 — forked from DungGramer/fastest_for.js
Find fastest way to loop through an array in Javascript
const { performance } = require('perf_hooks');
const assert = require('assert');
const DURATION_COLUMN = 'time[ns]';
// Create 1000 random numbers
const createTestArray = length => Array.from({ length }, () => 1 + Math.floor(Math.random() * 1000));
const createReferenceArray = testArray => testArray.map(v => Math.ceil((v + 2) / 10));
const sumUp = array => array.reduce((sum, value) => sum + value, 0);
const computeBenchmark = v => Math.ceil((v + 2) / 10);
@DungGramer
DungGramer / fastest_for.js
Last active October 16, 2023 06:40
Find fastest way to loop through an array in Javascript
const {performance} = require('perf_hooks');
// Create 1000 random numbers
const arr = length =>
Array.from({length}, () => Math.floor(Math.random() * 1000));
function record(arr) {
const result = [];
function timeRun(callback, message) {
@jcubic
jcubic / cdn.md
Last active April 17, 2025 05:10
How to setup a literally free CDN
@samba
samba / shopify.datalayer.html
Last active January 20, 2025 22:07
Shopify DataLayer Checkout
{% if first_time_accessed %}
<script>
(function(dataLayer){
var customer_type = ({{customer.orders_count}} > 1) ? 'repeatcustomer' : 'newcustomer';
var discounts = "{{ order.discounts | map: 'code' | join: ',' | upcase}}";
function strip(text){
return text.replace(/\s+/, ' ').replace(/^\s+/, '').replace(/\s+$/, '');
}
@khoatran
khoatran / TextUtil.php
Last active April 17, 2024 10:21
Convert Vietnamese string to slug
<?php
class TextUtil {
public static function sanitize($title) {
$replacement = '-';
$map = array();
$quotedReplacement = preg_quote($replacement, '/');
$default = array(
'/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ|À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ|å/' => 'a',
'/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ|È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ|ë/' => 'e',
'/ì|í|ị|ỉ|ĩ|Ì|Í|Ị|Ỉ|Ĩ|î/' => 'i',
@JamesMessinger
JamesMessinger / IndexedDB101.js
Last active April 14, 2025 16:34
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});