Skip to content

Instantly share code, notes, and snippets.

@rhwy
rhwy / Domain_Application.cs
Last active March 11, 2020 22:51
Refactored version of SmartHelloWorld.
public class Application
{
IOutput output;
public Application(IOutput output)
{
this.output = output;
}
public void Run(string name)
{
if (ApplicationTime.Now.Hour >= 6 && ApplicationTime.Now.Hour < 12 )
@rhwy
rhwy / init-solution.sh
Created March 9, 2020 00:25
A very simple script to build generic template to keep on top of your dotnet exercices folder that allows you to quickly scaffold solution and projects structure
mkdir $1
cd $1
git init
echo "bin" >> .gitignore
echo "obj" >> .gitignore
git config core.autocrlf false
git add -A && git commit -m "init repo with gitignore"
mkdir src
mkdir src/$1.App
mkdir src/$1.Core

You'll have to create a Smart Hello World.

Your app need to take a name (by default world if none is provided) and write a greeting depending on the time of the day:

  • Good morning X if current hour is < 12h00
  • Good afternoon X if current hour is > 12h00 and < 20h00
  • Good night Xif current hour is after 20h00 and before 6h00 in the morning

You need to make it right:

  • take care of the boundaries of the system (what are your functional code and your technical code, what are invariants,...)
  • your business code should be testable
using System;
using System.Collections.Generic;
namespace DI2
{
using MonApp;
using MonApp.Adapters;
class Program
{
static void Main(string[] args)
@rhwy
rhwy / Nancy.ViewEngines.NancyRazorLight.cs
Created April 19, 2018 11:26
Nancy 2 RazorLight view engine wrapper for RazorLight templating engine
namespace Nancy.ViewEngines.NancyRazorLight
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Nancy.Responses;
using RazorLight;
using System.Linq;
@rhwy
rhwy / choco-installs.ps1
Last active April 7, 2018 16:07
Install workstation with chocolatey
cinst python -y
cinst nodejs -y
cinst jre8 -y
cinst git.install -y
cinst dotnetcore-sdk -y
cinst dotnet4.7.1 -y
cinst azure-cli -y
cinst microsoftazurestorageexplorer -y
cinst ngrok -y
@rhwy
rhwy / win2018inst.bat
Created April 7, 2018 14:31
Install workstation with chocolatey
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" > "c:\install-log.txt"
cinst googlechrome -y

#hello

Keybase proof

I hereby claim:

  • I am rhwy on github.
  • I am rhwy (https://keybase.io/rhwy) on keybase.
  • I have a public key whose fingerprint is B16B AF86 1DC2 478C F7FC 0BBF 7111 E669 FBFD 11A9

To claim this, I am signing this object:

@rhwy
rhwy / gist:72eb2936ad045b300f48
Created November 26, 2014 17:16
NancyFX returning struct as Json
public class HomeModule : NancyModule
{
public HomeModule ()
{
Get ["/"] = p => "hello";
Get ["/{id}/{user}"] = p => {
User user = new User(p.id,p.user);
return Negotiate.WithModel(user);
};