Skip to content

Instantly share code, notes, and snippets.

View Aimeast's full-sized avatar
🙃
There is no typing

Aimeast

🙃
There is no typing
View GitHub Profile
@Aimeast
Aimeast / Program.cs
Created January 26, 2022 16:03
Add headers to PDF files with Spire.Pdf
using Spire.Pdf;
using Spire.Pdf.Graphics;
// Main call
static void AddHeader(PdfPageBase page, string left, string center, string right)
{
var state = page.Canvas.Save();
RotatePage(page);
AddHeaderWithRotatedPage(page, left, center, right);
page.Canvas.Restore(state);
@Aimeast
Aimeast / LimitedConcurrencyLevelTaskScheduler.cs
Created April 4, 2017 14:06
LimitedConcurrencyLevelTaskScheduler.cs
//--------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: LimitedConcurrencyTaskScheduler.cs
// Source: https://code.msdn.microsoft.com/vstudio/Execution-Time-Based-dd4dbdb6/sourcecode?fileId=67470&pathId=1378361369
// Modified for .net core
//--------------------------------------------------------------------------
using System;
Alice->Bob: Hello Bob, how are you?
Note right of Bob: Bob thinks
Bob-->Alice: I am good thanks!
#region Socket operations
protected IAsyncResult BeginSocketRead(int length, ApmCallback callback)
{
return BeginSocketIO(new byte[length], callback, _socket.BeginReceive, _socket.EndReceive);
}
protected IAsyncResult BeginSocketWrite(byte[] data, ApmCallback callback)
{
return BeginSocketIO(data, callback, _socket.BeginSend, _socket.EndSend);
}
@Aimeast
Aimeast / RIR Delegations.md
Last active December 14, 2023 10:59
RIR Delegations

http://www-public.it-sudparis.eu/~maigron/RIR_Stats/index.html

RIR Delegations

These pages provide statistics on IP addresses and ASN numbers delegated by RIRs to each country in their geographic area. Delegation details for each country are also available.

These statistics are generated automatically from the RIRs delegation files available via FTP:

ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-extended-latest ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-extended-latest

@Aimeast
Aimeast / CancellationToken.cs
Last active August 29, 2015 14:03
Test CancellationToken
static void Main()
{
var source = new CancellationTokenSource();
var task1 = Task.Factory.StartNew(() =>
{
Console.WriteLine("run task1");
Task.Delay(2000).Wait();
Console.WriteLine("after delay task1");
source.Token.ThrowIfCancellationRequested();
Console.WriteLine("no exec task1");
@Aimeast
Aimeast / jQueryPlugin.js
Last active August 29, 2015 13:57
jQuery Plugins Working for GitCandy
/*
GitCandy is a Git platform based on ASP.NET MVC
Source on: http://github.com/Aimeast/GitCandy
Demo on: http://git.53wb.com/
The MIT License (MIT)
Copyright (c) 2014 Aimeast
*/
@Aimeast
Aimeast / Program.cs
Created February 16, 2014 15:35
Combine Highlight.js
// A highlight.js packer which work for Git Candy©
// The output please reference to https://github.com/Aimeast/GitCandy/blob/dev/GitCandy/Scripts/highlight.pack.js
class Program
{
static void Main(string[] args)
{
using (var writer = new StreamWriter("highlight.pack.js"))
{
writer.WriteLine("//https://github.com/isagalaev/highlight.js");
@Aimeast
Aimeast / Inlining.cs
Last active February 21, 2017 17:04
Test C# inlining method (framework 4.5)
/*
* Following code for test an method will be inlined by JIT or not
* Tested on Framework 4.5, Win8 x64
*
* http://blogs.msdn.com/b/ericgu/archive/2004/01/29/64717.aspx
* http://blogs.microsoft.co.il/blogs/sasha/archive/2012/01/20/aggressive-inlining-in-the-clr-4-5-jit.aspx
*/
using System;
using System.Diagnostics;
public static class CommitLogExtension
{
public static IEnumerable<Commit> PathFilter(this IEnumerable<Commit> log, string path)
{
if (string.IsNullOrEmpty(path))
return log;
return log.Where(s =>
{
var pathEntry = s[path];