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
{
public class Program
{
private static void Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args).Build();
using var scope = host.Services.CreateScope();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<Program>>();
var configuration = scope.ServiceProvider.GetService<IConfiguration>();
public class Program
{
private static void Main(string[] args)
{
var host = Host.CreateDefaultBuilder(args).Build();
using var scope = host.Services.CreateScope();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<Program>>();
var configuration = scope.ServiceProvider.GetService<IConfiguration>();
macro_rules! raindrop {
($func:ident, $factor:expr, $text:expr) => {
fn $func<'a>(n: u32) -> Option<&'a str> {
if n % $factor == 0 {
return Some($text);
}
return None;
}
};
}
pub fn raindrops(n: u32) -> String {
let mut result = String::new();
if let Some(v) = is_factor_of_three(n) {
result.push_str(v);
}
if let Some(v) = is_factor_of_five(n) {
result.push_str(v);
}
use config::{Config, ConfigError, Environment, File};
use serde_derive::Deserialize;
use std::env;
#[derive(Deserialize)]
pub struct ServerSettings {
pub host: String,
pub port: i32,
}
@ircnelson
ircnelson / .env
Created June 22, 2020 06:21
Getting configurations in Rust lang
SERVER.PORT=5001
[dependencies]
serde = "1.0.113"
serde_derive = "1.0.113"
dotenv = "0.15.0"
config = "0.10.1"
@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:
[
{ "type": "escape", "title": "esc", "align": "left" },
{ "type": "exitTouchbar", "title": "", "align": "left", "bordered": false, "width": 24,
"image": {
"base64":
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAQ6wAAEOsBUJTofAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6dGlmZj0iaHR0cDovL25zLmFkb2JlLmNvbS90aWZmLzEuMC8iPgogICAgICAgICA8dGlmZjpPcmllbnRhdGlvbj4xPC90aWZmOk9yaWVudGF0aW9uPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KTMInWQAAHktJREFUeAG9Wwl4VdW1Xme4U+6QOSETAUIShASZJwkGFZCZKmF4aKsdbIvazzpbn890tPpsqdU+q3Z4trZWsJaKA1QroFYCAhaZhzAEApnne3OHM7x/7XtPuIlBk762G87d5+xxrX+vtfbaQxT6x4JkVausJLm8vFLatm2baaX9u+LKykoZfSmTJ0+WDh069O/qlgTzCxfOTB41orTU6rW8vFy13v8d8b+7v3ieBABrPrfoja9/YaU5a9rMP979tRszuEB