Skip to content

Instantly share code, notes, and snippets.

@abc126
abc126 / Setup.iss
Created November 12, 2018 03:36 — forked from canton7/Setup.iss
Installing .NET Framework 4.6.1 with Inno Setup
#define DotNetRuntimeExe "NDP461-KB3102436-x86-x64-AllOS-ENU.exe"
[CustomMessages]
InstallingDotNetFramework=Installing .NET Framework. This might take a few minutes...
DotNetFrameworkFailedToLaunch=Failed to launch .NET Framework Installer with error "%1". Please fix the error then run this installer again.
DotNetFrameworkFailed1602=.NET Framework installation was cancelled. This installation can continue, but be aware that this application may not run unless the .NET Framework installation is completed successfully.
DotNetFrameworkFailed1603=A fatal error occurred while installing the .NET Framework. Please fix the error, then run the installer again.
DotNetFrameworkFailed5100=Your computer does not meet the requirements of the .NET Framework. Please consult the documentation.
DotNetFrameworkFailedOther=The .NET Framework installer exited with an unexpected status code "%1". Please review any other messages shown by the installer to determine whether the installation completed successfully, and abort this
@abc126
abc126 / IsInDesignMode.cs
Created December 7, 2018 15:38
IsInDesignMode
public static bool IsInDesignMode()
{
if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
return true;
if (Process.GetCurrentProcess().ProcessName == "devenv") return true;
return false;
}
public class RadioGroupBox : GroupBox
{
public event EventHandler SelectedChanged = delegate { };
int _selected;
public int Selected
{
get
{
return _selected;
public static void SendACommandToAutoCAD(string command)
{
MgdAcDocument doc = MgdApplication.DocumentManager.MdiActiveDocument;
if(doc == null)
{
MessageBox.Show("当前无活动文档,请新建或切换至活动文档后再执行命令", "无法获取活动文档", MessageBoxButtons.OK, MessageBoxIcon.Stop);
return;
}
// 根据是否有命令运行决定esc的数量
string esc = "";
worksheet.TrimLastEmptyRows();
public static void TrimLastEmptyRows(this ExcelWorksheet worksheet)
{
while (worksheet.IsLastRowEmpty())
worksheet.DeleteRow(worksheet.Dimension.End.Row);
}
public static bool IsLastRowEmpty(this ExcelWorksheet worksheet)
{
@abc126
abc126 / split string
Created October 31, 2019 03:24
split string c++
void split(const string& s, vector<string>& tokens, const string& delimiters = " ")
{
string::size_type lastPos = s.find_first_not_of(delimiters, 0);
string::size_type pos = s.find_first_of(delimiters, lastPos);
while (string::npos != pos || string::npos != lastPos) {
tokens.push_back(s.substr(lastPos, pos - lastPos));//use emplace_back after C++11
lastPos = s.find_first_not_of(delimiters, pos);
pos = s.find_first_of(delimiters, lastPos);
}
}
@abc126
abc126 / SimpleHttpServer.cs
Created November 29, 2019 02:57 — forked from augustoproiete/SimpleHttpServer.cs
C# Based HttpListener Static File Web Server
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Westwind.Utilities;
namespace Westwind.WebConnection
@abc126
abc126 / SimpleLogger.cs
Created December 6, 2019 09:30
SimpleLogger
using System;
using System.IO;
using System.Text;
using System.Threading;
namespace Clearcove.Logging
{
public sealed class Logger
{
#region Log File Writing
@abc126
abc126 / CallerMemberNameAttribute
Created January 10, 2020 18:13
CallerMemberNameAttribute
namespace System.Runtime.CompilerServices {
sealed class CallerMemberNameAttribute : Attribute { }
}
@abc126
abc126 / real.py
Created May 1, 2021 16:29 — forked from alfredodeza/real.py
Real time subprocess stdout/stderr
import logging
import threading
import os
import subprocess
logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO)
class LogPipe(threading.Thread):