Skip to content

Instantly share code, notes, and snippets.

View yuessir's full-sized avatar
🎯
Focusing

yuessir yuessir

🎯
Focusing
View GitHub Profile
@yuessir
yuessir / gist:38a1f858eb092465722f8dab347862cd
Created October 18, 2022 09:19
print leet code 70 all sooutions
/// <summary>
/// Gets up stairs path.
/// </summary>
/// <param name="res">結果集合.</param>
/// <param name="path">The path.</param>
/// <param name="totalStairs">樓梯總數.</param>
/// <param name="stepMethod">可能的步進階數.</param>
/// <returns></returns>
private static List<List<int>> GetUpStairsPath(List<List<int>> result, List<int> goThroughPath, int totalStairs,int[] stepMethod)
{
@yuessir
yuessir / gist:e7e3d31be23694bcd04dfd44f2a7b5b6
Created June 16, 2022 05:55
Change python version on per user basis Debian
Change python version on per user basis
To change a python version on per user basis you simply create an alias within user’s home directory. Open ~/.bashrc file and add new alias to change your default python executable:
alias python='/usr/bin/python3'
Once you make the above change, re-login or source your .bashrc file:
$ . ~/.bashrc
@yuessir
yuessir / gist:6612c713cde20950888f9eb10b164bf8
Last active June 16, 2022 04:55
WSL2 更換systemd 使用arkane-systems/genie
# update software repositories
$sudo apt update
# install available software updates
$sudo apt upgrade
# install prerequisites
$sudo apt install lsb-release wget openssl apt-transport-https -y
# switch to root role
$sudo -s
@yuessir
yuessir / gist:0366e33cf0179a08a60d422bcbab77f9
Created May 26, 2022 08:28
解決chrome remote 遠端連線速度慢
PS C:\Program Files (x86)\Google\Chrome Remote Desktop\101.0.4951.13> Get-WmiObject Win32_process -Filter 'name="remoting_host.exe"' | ForEach-Object {$_.SetPriority(128)}
__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
@yuessir
yuessir / DotNetCoreDirectoryGetParentTest
Last active December 19, 2018 09:45
Dot Net Core Directory.GetParent Test
string suffixSlash = @"C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug\netcoreapp2.1\";
string suffixNoSlash = @"C:\Users\KKK\source\repos\DotNetCoreDirectoryGetParentTest\DotNetCoreDirectoryGetParentTest\bin\Debug\netcoreapp2.1";
string currentDomainBaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
string appContextBaseDirectory = AppContext.BaseDirectory;
string str1 = Directory.GetParent(suffixSlash).FullName;
string str2 = Directory.GetParent(suffixSlash).Parent.FullName;
string str3 = Directory.GetParent(str1).FullName;
string str4 = Directory.GetParent(suffixNoSlash).FullName;
@yuessir
yuessir / SleepSort
Last active November 9, 2018 10:13
Using C# Thread.Sleep to Sort Array Ascending For FUN XDDDDDD
private static void Main(string[] args)
{
int[] nums = new int[] { 13, 3, 889, 5455, 1, 152, 990 };
ParameterizedThreadStart myPar = new ParameterizedThreadStart(SleepSort);
foreach (var num in nums)
{
Thread myThread = new Thread(myPar);
myThread.IsBackground = true;
myThread.Start(num);
}
@yuessir
yuessir / gist:4efc67ad80b0809ab1707bc7ce20913e
Created October 2, 2018 08:17
Chop Decimals (NO Rounding) C#
#Implementing IFormatProvider, ICustomFormatter
forking from https://stackoverflow.com/a/28342440/4246719
public class FormatProvider : IFormatProvider, ICustomFormatter
{
public object GetFormat(Type formatType)
{
if (formatType == typeof(ICustomFormatter))
{
return this;
}
@yuessir
yuessir / Parsing Context.Request to JSON Format
Created September 19, 2018 10:50
Parsing Context.Request to JSON Format in Webapi .Net core
[HttpPost("TestPost")]
public ActionResult<string> TestPost()
{
string jsonText = "";
var context = HttpContextProvider.Current;
// context.Request.EnableRewind();
try
{
// shared variables
// private static ThreadLocal<int> local = new ThreadLocal<int>();//output 53000 0;
private static AsyncLocal<int> local = new AsyncLocal<int>();//output 53000 53000;
private static void Main(string[] args)
{
// declare a delegate
Action act = async () =>
{