Skip to content

Instantly share code, notes, and snippets.

View monoman's full-sized avatar
🔗
Interlocking...

Rafael Teixeira monoman

🔗
Interlocking...
View GitHub Profile
@monoman
monoman / UberQueue.cs
Created August 16, 2021 21:34
My Take on David Fowler UberQueue Challenge
// See https://aka.ms/new-console-template for more information
using System.Collections;
using System.Collections.Generic;
Console.WriteLine("Hello, UberQueue!");
var uq = new UberCollections.UberQueue<string>(
new TestAsyncQueue(delay: 500, "One", "Two", "Three"),
new TestAsyncQueue(delay: 1000, "Four", "Five"),
new TestAsyncQueue(delay: 150, "Six", "Seven", "Eight", "Nine")
@monoman
monoman / FAQ-Document_Registry_on_REST.md
Last active December 28, 2020 22:15
Trying to add a Document file to a chain through the IL2 Node’s REST API

FAQ - Document Registry on REST [DEPRECATED]

Scenario

Trying to add a Document file to a chain through the IL2 Node’s REST API

Questions

1 - Where should the document content be posted to?

The body content of the POST is the file content (as native unencoded bytes) and it should be posted to the URL built from the query parameters

Partial request path: /documents@t_HlFTTruR33B6_hsgfpq8bPCaADamwrfQy1stPJTkY?Cipher=None&Name=BlahBlah.txt

static void ConfigureLogger()
{
const string logConfig = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<log4net>
<root>
<level value=""INFO"" />
<appender-ref ref=""console"" />
</root>
<appender name=""console"" type=""log4net.Appender.ColoredConsoleAppender"">
<layout type=""log4net.Layout.PatternLayout"">
@monoman
monoman / TranslatableStrings_Example.cs
Last active August 29, 2015 14:23
TranslatableStrings aims to enable Roslyn to again be at peace with resources or any other translation mechanism when using string interpolation
var person="David";
Console.WriteLine($_"Hello {person}");
// Prints "Alô David" in pt-BR
Console.WriteLine($"Hello {person}");
// Prints "Hello David" in pt-BR
/* ---- MIT LICENSE ----
Copyright (c) 2011 John Gietzen
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:
@monoman
monoman / Thanks to Hao Kung, b_levitt
Created October 27, 2014 16:19
Add to Global.asax.cs and call InitJQuery on Application_Start() to avoid "WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'" on migrating to ASP.NET 4.5
Based on **b_levitt** answer to http://stackoverflow.com/questions/16660900/webforms-unobtrusivevalidationmode-requires-a-scriptresourcemapping-for-jquery
But avoiding hardcoding the jQuery version (doesn't play nice with nuget) by using some regex as explained by **Hao Kung** on http://stackoverflow.com/questions/12029161/version-wildcard-in-mvc4-bundle
@monoman
monoman / gist:2053145
Created March 16, 2012 22:08
Some things that could make ASP.NET MVC 4 Web API even better
// this offends my coding sensibility
public Contact GetContact(int id)
{
Contact contact = _repository.Get(id);
if (contact == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return contact;
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="nuspec"
targetNamespace="{0}"
elementFormDefault="qualified"
xmlns="{0}"
xmlns:mstns="{0}"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="package">
<xs:complexType>
@monoman
monoman / ReadonlyProperties.cs
Last active September 26, 2015 05:48
I would do differently on a light C# example from http://www.trelford.com/blog/post/LighterCSharp.aspx
public class Person {
public Person(string name, int age) {
_name = name;
_age = age;
}
private readonly string _name;
private readonly int _age;
/// Full name
public string Name { get _name; }
/// Age in years
@monoman
monoman / Boo Marvels - 1
Last active September 25, 2015 09:38
Boo's creator answering a question on Boolang list. Another wonder of meta-programming...
Daniel Brauer's Question:
Of course I just figured it out: I was trying to declare a bunch of floats like this:
[SerializeField]
m_forwardPower = 2f,
m_backwardPower = 1f,
m_strafePower = 0f,
m_maxVelocity = 5f,
m_turnSpeed = 3f,