Skip to content

Instantly share code, notes, and snippets.

View tranchausky's full-sized avatar
🏹
done

tranchausky

🏹
done
View GitHub Profile
@tranchausky
tranchausky / TextUtil.php
Created April 17, 2024 10:21 — forked from khoatran/TextUtil.php
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',
@tranchausky
tranchausky / IndexedDB101.js
Created October 26, 2023 09:45 — forked from JamesMessinger/IndexedDB101.js
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"});
@tranchausky
tranchausky / url-segment.js
Created June 29, 2020 03:03 — forked from jserrao/url-segment.js
Get Last Segment of a URL in Javascript
var pageURL = window.location.href;
var lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1);
console.log(lastURLSegment);
@tranchausky
tranchausky / checkout.liquid
Created June 18, 2020 08:31 — forked from bxmas13/checkout.liquid
Shopify Plus Checkout.liquid template. Can be used with Timber
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="{{ locale }}" dir="{{ direction }}" class="{{ checkout_html_classes }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, height=device-height, minimum-scale=1.0, user-scalable=0">
<title>{{ shop.name }} - {{ page_title }}</title>
{{ content_for_header }}