Skip to content

Instantly share code, notes, and snippets.

@rqx110
rqx110 / NewMongodbObjectId.cs
Last active August 2, 2018 06:52
生成类似Mongodb的ObjectId有序、不重复Guid
private static DateTime dt1970 = new DateTime(1970, 1, 1);
private static Random rnd = new Random();
private static readonly int __staticMachine = ((0x00ffffff & Environment.MachineName.GetHashCode()) +
#if NETSTANDARD1_5 || NETSTANDARD1_6
1
#else
AppDomain.CurrentDomain.Id
#endif
) & 0x00ffffff;
private static readonly int __staticPid = Process.GetCurrentProcess().Id;
@rqx110
rqx110 / AppDbContext.cs
Created August 15, 2018 01:33
EF core 2.0 批量注册entityTypeConfiguration
string typeName = typeof(IEntityTypeConfiguration<>).Name;
var assembly = Assembly.GetExecutingAssembly();
assembly.GetTypes()
.Where(w => w.GetTypeInfo().ImplementedInterfaces.Any(a => a.Name == typeName))
.ToList()
.ForEach(item =>
{
dynamic instance = item.FullName;
builder.ApplyConfiguration(assembly.CreateInstance(instance));
@rqx110
rqx110 / ObjectExtensions.cs
Created September 6, 2018 01:37
对象deep copy, 注意对象必须添加[Serializable]
using System;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace Abp.Extensions
{
public static class ObjectExtensions
{
public static T Dereference<T>(this object obj)
@rqx110
rqx110 / EnumExtensions.cs
Created September 6, 2018 01:40
获取Enum描述属性值
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using Abp.Application.Services.Dto;
namespace Abp.Extensions
{
public static class EnumExtensions
{
@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"
}
@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 / 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 / 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 / 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
@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);