Skip to content

Instantly share code, notes, and snippets.

View tieutantan's full-sized avatar
🍉
Focusing

Tran Ngoc Tan tieutantan

🍉
Focusing
View GitHub Profile
@tieutantan
tieutantan / file.php
Created February 25, 2019 19:06
PHP - Prepare process textarea
<?php
$files = $_POST['files_list'];
$filesArray = array_map("trim", explode("\n", $files));
$filesArray = array_filter($filesArray); // Remove empty array elements
$formatedFilesArray = array_unique($filesArray); // Deleting the duplicate items
@tieutantan
tieutantan / file.php
Created March 13, 2019 02:47
PHP - Remove URL text on string.
<?php
$string = preg_replace('/\b((https?|ftp|file):\/\/|www\.)[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $string);
@tieutantan
tieutantan / my.cnf
Created April 5, 2019 20:21 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated December 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
@tieutantan
tieutantan / editor.html
Created May 16, 2020 01:09
Hide license alert of TinyMCE
<style>
.tox-notifications-container {display: none !important;}
</style>
<script src="{{ asset('admin') }}/js/tinymce.min.js"></script>
<script>tinymce.init({selector:'textarea', height : "480"});</script>
@tieutantan
tieutantan / wait-el.js
Last active November 11, 2020 16:31 — forked from chrisjhoughton/wait-el.js
Wait for an element to exist on the page with jQuery
// Convert shop the look pricing (EURO only) to cart currency
var existGetTheLook = setInterval(function () {
if ($('.stl__presentmentPrice').length) {
clearInterval(existGetTheLook);
let price_needed = 'data-currency-' + cart_currency.toLocaleLowerCase();
$('span[class="stl__presentmentPrice"]').each(function (index, item) {
let price_by_currency = $(item).attr(price_needed);
@tieutantan
tieutantan / .gitignore
Created October 23, 2020 17:34
Git ignore for Shopify
# Shopify
/config
config.yml
# This file contains a list of files and folders to be ignored when
# committing to a git repository. Ignored files are both Slate project
# specific files as well as commonly ignored files on any project.
# For more information on this .gitignore files, see GitHub's
# documentation: https://help.github.com/articles/ignoring-files/
@tieutantan
tieutantan / gist:32095c490a1eb3462658e67296a21b64
Created November 30, 2020 17:58 — forked from carolineschnapp/gist:1002949
Related Products by Tags — to add to product.liquid
<!-- Solution brought to you by Caroline Schnapp -->
<!-- See this: http://wiki.shopify.com/Related_Products -->
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% if product.tags.size > 0 %}
<h3>{{ heading }}</h3>
<ul class="related-products"></ul>
@tieutantan
tieutantan / file.js
Last active December 18, 2020 04:24
English in text detection JS
function changeEngFont(selector) {
$(selector).contents().each(function () {
if (this.nodeType === 3) {
} else {
let value = this.innerHTML;
let isEnglish = value.search(/[^a-zA-Z]+/);
if(isEnglish === -1 || isEnglish === 3) {
$(this).css("font-family", "Baskerville, serif");
}
@tieutantan
tieutantan / popup.js
Created January 12, 2021 07:23
JS alert without URL on the top of modal
function silentAlert(messages) {
let iframeElement = '<iframe style="display: none;" id="silent_alert"></iframe>';
document.getElementsByTagName('body')[0].innerHTML += iframeElement;
let ifrm = document.getElementById('silent_alert');
ifrm = ifrm.contentWindow || ifrm.contentDocument.document || ifrm.contentDocument;
ifrm.document.open();
ifrm.document.write('<script>alert("' + messages + '");<\/script>');
ifrm.document.close();
}
@tieutantan
tieutantan / rate.php
Last active January 19, 2021 03:54
Rate times counter
<?php
$base = 15000000;
$rate = 0.04;
$i = 1;
while ($i <= 102) {
$base += $base * $rate;
echo PHP_EOL . $i . ' - ' . number_format($base);