Get Random String
using System;
using System.Text;
public class Program
{
public static void Main()
{
Console.WriteLine(GetRandomString(0));
Get Random String
using System;
using System.Text;
public class Program
{
public static void Main()
{
Console.WriteLine(GetRandomString(0));
Given two arithmetic expressions e1 and e2 that have same four operands, judge if they are equivalent. Two expression are equivalent if they can be arranged to be the same expression according to mathematical properties. Return true if they are equivalent, otherwise false.
Example 1:
Option Explicit | |
Public Function RegExpTest(text As String, pattern As String, Optional match_case As Boolean = True) As Boolean | |
Dim regex As Object | |
On Error GoTo ErrHandl | |
Set regex = CreateObject("VBScript.RegExp") | |
regex.pattern = pattern | |
regex.Global = True |
$ErrorActionPreference = 'Stop' | |
# Create sheet if not exists | |
Function CreateSheetIfNotExist($Wb, $SheetName) | |
{ | |
foreach($Ws In $Wb.Worksheets) { | |
If ($SheetName -ieq $Ws.Name) { | |
return $Ws | |
} | |
} |
#Requires -RunAsAdministrator | |
# Pin packages. | |
$packages = @( | |
'emacs' | |
'firefox' | |
'vscode' | |
'vscode.install' | |
'microsoft-windows-terminal' | |
) |
Start a WinMerge window to compare two files and return immediatelly.
Start-Process winmergeu.exe -WindowStyle Hidden "/s /t text ""left_file.txt"" ""right_file.txt"""
# Export Excel sheet to CSV file | |
# $File: file path | |
# $SheetNames: An array, sheet names to export. | |
Function Export-ExcelToCsv ($File, $SheetNames) { | |
$Excel = New-Object -ComObject Excel.Application | |
# SaveAs will overwrite existing file | |
$Excel.Application.DisplayAlerts = $False | |
$wb = $Excel.Workbooks.Open($File) |
# Import public key as the first time | |
pubkey_url=$( | |
curl -s \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/ProtonMail/proton-bridge/releases/latest \ | |
| grep "browser_download_url" | grep -E "pubkey.gpg\"$" \ | |
| awk -F "\"" '{print $4}' | |
) | |
pubkey_file=$(basename "$pubkey_url") |
Set default encoding of Out-File. See about_Character_Encoding.
# On Windows Powershell
# Out-File and the redirection operators > and >> create UTF-16LE.
# Set defautl encoding of Out-File (or > redirection) to UTF-8 (with BOM).
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'