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 / install_docker.sh
Last active November 26, 2023 14:10
Script To Install Newest Docker + Docker Compose On Ubuntu 22
#!/bin/bash
# Update the package index
sudo apt-get update
# Install packages to allow apt to use a repository over HTTPS
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
@tieutantan
tieutantan / README.md
Created September 24, 2023 13:42 — forked from 4wk-/README.md
Clean uninstall then reinstall of WSL on Windows 10, with systemD support

Uninstall then reinstall WSL on Windows 10 (clean way)

Background

I've been using wsl (version 2) with genie mod for years without issue, but one day, Windows 10 finally catch up on wsl Windows 11 features and gives us a way to use systemD natively.

I wanted to use the new "right way" to enable systemD on Windows Subsystem for Linux (without genie), and I also had a (probably related) infinite Windows RemoteApp error poping in.

Fixing it

A - Uninstall wsl and related stuff

  1. In powershell (as admin)
@tieutantan
tieutantan / remove-file-json.js
Created February 25, 2023 12:14
Mass Update File on Windows
const fs = require('fs');
const path = require('path');
const directoryPaths = [
'./Photos from 2014',
'./Photos from 2015',
'./Photos from 2016',
'./Photos from 2017',
'./Photos from 2018',
'./Photos from 2019',
@tieutantan
tieutantan / .gitignore
Created February 18, 2022 14:50
.gitignore for folder
*
!.gitignore
@tieutantan
tieutantan / di.xml
Created August 24, 2021 02:09 — forked from 0-Sony/di.xml
Magento2 : Add Custom Store Configuration exposed to graphQL
<!-- etc/graphql/di.xml -->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
<arguments>
<argument name="extendedConfigData" xsi:type="array">
<item name="custom_config" xsi:type="string">mynamespace_mymodule/general/custom_config</item>
</argument>
@tieutantan
tieutantan / Dockerfile
Created August 8, 2021 05:05
Dockerfile for PHP8 + Laravel
FROM php:8.0.3-apache-buster
# Surpresses debconf complaints of trying to install apt packages interactively
# https://github.com/moby/moby/issues/4032#issuecomment-192327844
ARG DEBIAN_FRONTEND=noninteractive
# Update
RUN apt-get -y update --fix-missing && \
apt-get upgrade -y && \
@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);
@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 / 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 / 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>