Skip to content

Instantly share code, notes, and snippets.

View litan1106's full-sized avatar

Li Tan litan1106

View GitHub Profile
@litan1106
litan1106 / wsl-systemd.sh
Last active April 17, 2023 20:53
wsl-systemd
# Install the latest wsl2 with systemd support
# https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
# Update the latest wsl
wsl --update --web-download
# Install Ubuntu with username vagrant
wsl --install -d Ubuntu-20.04
# Set Ubuntu as default distro
@litan1106
litan1106 / idsrv4-sha256-secret.cs
Created May 12, 2020 15:54
idsrv4-sha256-secret.cs
using System;
using System.Text;
using System.Security.Cryptography;
public class Program
{
public static void Main()
{
Console.WriteLine(GetSHA256Hash("secret"));
@litan1106
litan1106 / gcrgc.sh
Last active February 5, 2020 19:50 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@litan1106
litan1106 / pinncle-cart-ga
Last active November 7, 2016 16:29
pinncle-cart-ga
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxx']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
@litan1106
litan1106 / entware-ng-r7000-arm
Last active November 24, 2020 22:23
entware-ng-dd-wrt-R7000-arm
#Disable router dnsmasq and privoxy
Go to Setup and deactivate the DHCPD service
Go to Setup and disable DHCP Server and all dnsmasq options
Go to Service and disable all privoxy options
#Save startup script
/opt/etc/init.d/rc.unslung start
@litan1106
litan1106 / sql:prestashop-delete-orders
Created April 14, 2015 02:32
sql:prestashop-delete-orders
delete from ps_cart;delete from ps_cart_product;delete from ps_message;delete from ps_order_detail;delete from ps_order_history;delete from ps_orders;
@litan1106
litan1106 / sql:prestashop-product
Created April 14, 2015 02:16
sql:prestashop-product
SELECT p.id_product AS 'ID',
p.active AS 'Active (0/1)',
pl.name AS 'Name',
p.id_category_default AS 'Default Category',
p.price AS 'Price tax excl.',
p.quantity AS 'Quantity',
pl.description_short AS 'Short description',
pl.description AS 'Description',
pl.link_rewrite AS 'URL rewritten',
p.available_for_order AS 'Available for order',
@litan1106
litan1106 / sql:woocommerce-product
Created April 13, 2015 22:51
sql:woocommerce-product
select distinct
# uncomment these rows for debugging
# p.ID,
# v.ID,
if( isnull(vm_sku.meta_value), pm_sku.meta_value, vm_sku.meta_value ) as 'sku',
p.post_title,
# need to cast prices to decimal because the datatype is not enforced otherwise
@litan1106
litan1106 / PrintScript:Outlook
Last active August 29, 2015 14:15
PrintScript:Outlook
Sub PrintEmailWithoutTheHeader(olkMsg As Outlook.MailItem)
Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Dim objIE As Object, strHead As String, strFoot As String
strHead = GetIEHeaderFooter("header")
strFoot = GetIEHeaderFooter("footer")
SetIEHeaderFooter "header", ""
SetIEHeaderFooter "footer", ""
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
@litan1106
litan1106 / PrintMail:Outlook
Last active August 29, 2015 14:15
PrintMail:Outlook
Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.