Skip to content

Instantly share code, notes, and snippets.

@ircnelson
ircnelson / RedisJobQueue.cs
Created July 13, 2021 16:27 — forked from tenowg/RedisJobQueue.cs
A Message/Job Queue based on StackExchange.Redis and Redis Server
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Redis;
namespace CitySurvival.Redis
{
@ircnelson
ircnelson / EventManager.cs
Created April 26, 2020 14:06 — forked from bendangelo/EventManager.cs
Unity3D C# Event Manager
/*
* Copyright 2017 Ben D'Angelo
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
* to whom the Software is furnished to do so, subject to the following conditions:
using UnityEngine;
public class CubePlacer : MonoBehaviour
{
private Grid grid;
private void Awake()
{
grid = FindObjectOfType<Grid>();
}
using UnityEngine;
public class Grid : MonoBehaviour
{
[SerializeField]
private float size = 1f;
public Vector3 GetNearestPointOnGrid(Vector3 position)
{
position -= transform.position;
@ircnelson
ircnelson / WebApiSimplePatchSample.cs
Created February 19, 2018 16:40 — forked from tugberkugurlu/WebApiSimplePatchSample.cs
ASP.NET Web API Patch Sample.
public class Car {
public int Id { get; set; }
[Required]
[StringLength(20)]
public string Make { get; set; }
[Required]
[StringLength(20)]
@ircnelson
ircnelson / rust-lifetime-examples-2.rs
Created April 6, 2017 16:29 — forked from anonymous/playground.rs
Rust Lifetime Playground
use std::collections::HashMap;
fn main() {
struct User<'a> {
name: &'a str,
}
impl<'a> User<'a> {
fn new(uname: &'a str, pwd: &'a str) -> User<'a> {
User { name: uname }
@ircnelson
ircnelson / rust-lifetime-examples.rs
Last active April 6, 2017 14:25 — forked from anonymous/playground.rs
Rust Playground (Lifetime examples)
pub struct TextEditor {
text: String //Private member variable
}
impl TextEditor {
pub fn new() -> TextEditor {
TextEditor{text: String::new()}
}
pub fn add_char(&mut self, ch : char) {
@ircnelson
ircnelson / person.rs
Last active April 1, 2017 16:14 — forked from anonymous/playground.rs
Rust design struct
#[derive(Debug)]
struct Person {
name: String,
never_change_this: i32,
}
impl Person {
fn new(name: String, never_change_this: i32) -> Person {
Person {
name: name,
never_change_this: never_change_this,
@ircnelson
ircnelson / ExecutionResult.cs
Created March 21, 2017 21:17 — forked from vladikk/ExecutionResult.cs
Command execution result object for CQRS based systems
using System;
namespace Example
{
public abstract class ExecutionResult
{
protected ExecutionResult(Guid aggregateId, Guid commandId, DateTime executedOn)
{
AggregateId = aggregateId;
CommandId = commandId;
@ircnelson
ircnelson / Program.cs
Created January 12, 2017 12:59 — forked from TerribleDev/Program.cs
parsing args in dotnet core
public static void Main(string[] args)
{
var app = new Microsoft.Extensions.CommandLineUtils.CommandLineApplication();
var catapult = app.Command("catapult", config => {
config.OnExecute(()=>{
config.ShowHelp(); //show help for catapult
return 1; //return error since we didn't do anything
});
config.HelpOption("-? | -h | --help"); //show help on --help
});