Skip to content

Instantly share code, notes, and snippets.

@xdedss
xdedss / TimeoutAction.cs
Last active February 15, 2024 08:17
An attempt to run actions with timeout in C#
using System;
using System.Threading;
public class TimeoutAction
{
private Thread timerThread;
private Thread mainThread;
private AutoResetEvent timerStartEvent = new AutoResetEvent(false);
private AutoResetEvent timerPreparedEvent = new AutoResetEvent(false);
@Ahmed-Abdelhameed
Ahmed-Abdelhameed / DelayFadeOutSampleProvider.cs
Last active June 7, 2022 06:19 — forked from markheath/DelayFadeOutSampleProvider.cs
NAudio basic example of how to begin a fade out after a certain number of milliseconds have elapsed
// Define other methods and classes here
/// <summary>
/// Sample Provider to allow fading in and out
/// </summary>
public class DelayFadeOutSampleProvider : ISampleProvider
{
enum FadeState
{
Silence,
FadingIn,
@joelmartinez
joelmartinez / iter.cs
Created August 1, 2014 21:26
A simple extension method that gives you the "Iter" function from F#
static class x10 {
public static IEnumerable<T> Iter<T>(this IEnumerable<T> list, Action<T> action) {
foreach (var n in list) {
action (n);
yield return n;
}
}
}
@rb2k
rb2k / gist:8372402
Last active April 15, 2024 19:30
A jenkins script to clean up workspaces on slaves
// Check if a slave has < 10 GB of free space, wipe out workspaces if it does
import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
for (node in Jenkins.instance.nodes) {
@joelmartinez
joelmartinez / GameOfLife.cs
Created September 5, 2011 03:24
Conway's Game Of Life in C#
using System;
using System.Threading.Tasks;
namespace Life
{
public class LifeSimulation
{
private bool[,] world;
private bool[,] nextGeneration;
private Task processTask;