Skip to content

Instantly share code, notes, and snippets.

View Nucs's full-sized avatar

Eli Belash Nucs

  • Haifa, Israel
View GitHub Profile
@Nucs
Nucs / ~\.claude\settings.json
Created December 15, 2025 15:42
Claude Code hook to print SessionId and cli command "claude --resume <session_id>" for convenient copy for later resume or restart.
{
"hooks": {
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "node -e \"let i='';process.stdin.on('data',c=>i+=c);process.stdin.on('end',()=>{try{const d=JSON.parse(i);const r='claude --resume '+d.session_id+' --debug';const w=r.length+16;const ln='═'.repeat(w);console.error('\\n'+ln);console.error(' Dir: '+d.cwd);console.error(' Reason: '+d.reason);console.error(' Resume: '+r);console.error(ln);process.exit(2)}catch(e){}})\""
}
]
@Nucs
Nucs / MultiKeyDictionary.cs
Last active April 1, 2024 20:18
A technique to define a dictionary with any kind of keys combination, supporting items with N keys and M keys. All works as long as they implement Equals and GetHashcode, or using IEquitable
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
var specificCombinationDictionary = new MultikeyDictionary<(int,int), string>();
specificCombinationDictionary[(1, 2)] = "3";
var anyKeyDictionary = new MultikeyDictionary<ITuple, string>();
anyKeyDictionary[(1, 2)] = "3";
anyKeyDictionary[("str", DateTime.UtcNow.Date)] = "undefined err";
anyKeyDictionary[(1, 3, 5, "what? a string?!", ("sub?", "Tuple??"))] = "undefined err";
@Nucs
Nucs / MemoryInflator.cs
Created June 9, 2022 10:20
Memory Inflating Tool used to allocate memory while preventing windows RAM compression and disk caching
using System.Runtime.InteropServices;
var alloc = new Allocation();
Console.WriteLine("Hey, this tool will allocate how much memory you'll type in and reallocate ");
try {
Task.Run(async () => {
while (true) {
await Task.Delay(60000).ConfigureAwait(false);
if (!alloc.Buffer.HasValue)
continue;
@Nucs
Nucs / issue400.cs
Last active September 29, 2019 12:29
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RegenTesting
{
class Shape
{
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NumSharp.Backends;
using NumSharp.Backends.Unmanaged;
using NumSharp.Memory.Pooling;
using NumSharp.Utilities;
namespace NumSharp.Benchmark.Unmanaged
{
import numpy as np
errors = 0
rights = 0
outputShapes = list()
def operator_(left, right, msg):
global errors, rights, outputShapes
print("")
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NumSharp.Backends.Unmanaged;
using NumSharp.Memory.Pooling;
using NumSharp.Utilities;
namespace NumSharp.Benchmark.Unmanaged
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
namespace OMath.Benchmarks
{
//| Method | Mean | Error | StdDev | Median | Min | Max | Ratio | RatioSD |
//|--------------------------------------- |----------:|----------:|----------:|----------:|----------:|----------:|------:|--------:|
//| BasicClass | 2.542 us | 0.0209 us | 0.0299 us | 2.526 us | 2.516 us | 2.613 us | 1.00 | 0.00 |
//| InterfacedClass | 2.535 us | 0.0116 us | 0.0173 us | 2.528 us | 2.517 us | 2.570 us | 1.00 | 0.01 |
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
[SimpleJob(launchCount: 1, warmupCount: 3, targetCount: 15)]
public class ParallelFor {
private const int iterations = 10;
private int largeSize = 50_000;
DArray<int> a;
DArray<int> b;
private ParallelOptions settingsDistributed;
private ParallelOptions settingsConcurrent;