Skip to content

Instantly share code, notes, and snippets.

@rqx110
rqx110 / AvailablePorts.cs
Created February 14, 2023 08:30 — forked from jrusbatch/AvailablePorts.cs
Find an Available Port with C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation;
using System.Net;
namespace AvailablePort
{
class Program
@rqx110
rqx110 / ProcessManager.cs
Created February 14, 2023 07:16
限制一次只能打开一个程序
internal static class ProcessManager
{
public static void GetProcessLock()
{
ProcessManager.ProcessLock = new Mutex(false, "Global\\LuYao.Toolkit[" + ProcessManager.GetUid() + "]", ref ProcessManager.HasLock);
if (!ProcessManager.HasLock)
{
ProcessManager.ActiveWindow();
Environment.Exit(0);
}
@rqx110
rqx110 / RoundProgressBar.py
Created July 6, 2022 08:13
python 2.7 PyQt5 RoundProgressBar
from __future__ import division
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSize, Qt
from PyQt5.QtGui import QPainter, QPen, QColor, QFont
class RoundProgressBar(QtWidgets.QWidget):
def __init__(self, parent=None):
@rqx110
rqx110 / HexDump.cs
Last active August 21, 2021 07:19
hex dump
static void Main(string[] args)
{
var buffer = g().ToArray();
Console.WriteLine(HexDump(buffer));
IEnumerable<byte> g(){
foreach(var i in Enumerable.Range(0, 256)){
yield return (byte)i;
}
@ng-select-highlight: #9aabff;
@ng-select-primary-text: #495057;
@ng-select-disabled-text: #f9f9f9;
@ng-select-border: #e2e5ec;
@ng-select-border-radius: 4px;
@ng-select-bg: #ffffff;
@ng-select-selected: #f3f6f9;
@ng-select-marked: #f3f6f9;
@ng-select-placeholder: lighten(@ng-select-primary-text, 40);
@ng-select-height: calc(1.5em + 1.3rem + 2px);
@rqx110
rqx110 / retrying.py
Created April 3, 2020 07:16
retry operation
class Retrying:
def __init__(self, interval=1.0, delay=0.05, maxAttempts=None):
self.interval = interval
self.delay = delay
self.maxAttempts = maxAttempts
def __iter__(self):
class Iterator:
def __init__(self, interval, delay, maxAttempts):
self.attempt = 0
@rqx110
rqx110 / wait.py
Created April 3, 2020 07:14
Run func and return if it's True
import time
class TimeoutError(Exception):
def __init__(self, msg, code=1):
self.msg = msg
self.code = code
def __str__(self):
return 'TimeoutError: %s (code %d)' % (self.msg, self.code)
@rqx110
rqx110 / pycharm.bat
Created August 13, 2019 00:37 — forked from arieljannai/pycharm.bat
Add PyCharm to context menu (right click menu)
@echo off
@rem throw this file in jetbrains installation folder, it takes the last created PyCharm folder (the latest ide update) for the script
FOR /F "delims=" %%i IN ('dir /b /ad-h /t:c /od -filter "PyCharm*"') DO SET a=%%i
SET PyCharmPath=C:\Program Files (x86)\JetBrains\%a%\bin\PyCharm64.exe
echo %PyCharmPath%
echo Adding file entries
@rqx110
rqx110 / Snowflake.cs
Created April 24, 2019 07:21
分布式ID自增算法 Snowflake
using System;
namespace XCode.Common
{
#region 算法1
///// <summary>
///// 动态生产有规律的ID
///// </summary>
//public class Snowflake
@rqx110
rqx110 / CheckDotnetHostingBundleVersion.ps1
Created December 11, 2018 08:00 — forked from poychang/CheckDotnetHostingBundleVersion.ps1
[檢查 IIS 的 .NET Core Hosting Bundle 版本] #powershell
$DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core"
$DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath
$NotInstalled = $True
$DotNetCoreItems.GetSubKeyNames() | Where { $_ -Match "Microsoft .NET Core.*Windows Server Hosting" } | ForEach-Object {
$NotInstalled = $False
Write-Host "The host has installed $_"
}
If ($NotInstalled) {
Write-Host "Can not find ASP.NET Core installed on the host"
}