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 / .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 / 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 / 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 / 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 / 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 / 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 / get.php
Last active February 15, 2019 13:50
PHP get file size from remote URL without download
<?php
$url = 'https://speed.hetzner.de/100MB.bin';
$url = 'https://speed.hetzner.de/100MB.bin';
$url = 'https://speed.hetzner.de/10GB.bin';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@tieutantan
tieutantan / index.html
Created January 3, 2019 20:23
Use jQuery Ajax with PHP
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$.ajax({
url:"info.php",
type:'POST',
data:{name:your_name,age:your_age},
dataType:"html",
success:function(res) {
console.log(res);
@tieutantan
tieutantan / check.php
Created January 1, 2019 20:52
PHP - Valid IP and CIDR
<?php
function valid_ip_or_cidr($input)
{
if (is_int(strpos($value, '/')))
{
/*
* https://www.regexpal.com/93987
* if ip_cidr valid return 1, else 0
*/
@tieutantan
tieutantan / custom.css
Created December 26, 2018 17:14
Custom btn-xs on Bootstrap 4
/* docs - https://github.com/twbs/bootstrap/issues/21881#issuecomment-341972830 */
.btn-group-xs > .btn, .btn-xs {
padding : .25rem .4rem;
font-size : .875rem;
line-height : .5;
border-radius : .2rem;
}