Skip to content

Instantly share code, notes, and snippets.

class PersonService:
@property
def person_repo(self) -> PersonRepo:
return PersonRepoFactory().create()
def set_name(self, person_id: int, new_name: str) -> None:
p = self.person_repo.find(person_id)
p.name = new_name
self.person_repo.add_or_update(p)
class Dog(Mammal):
pass
class Cat(Mammal):
pass
TMammal = TypeVar("TMammal", bound=Mammal)
class MammalCollection(Generic[TMammal]):
def __init__(self, *mammals: TMammal) -> None:
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/>
<script src="http://cmx.io/v/0.1/cmx.js"></script>
<body>
<scene id="scene1">
<label t="translate(0,346)">
<tspan x="0" y="0em">A Comix Sample</tspan>
</label>
<actor t="translate(131,49)" pose="-11,9|-5,117|-11,99|-11,89|-11,79|-11,59|-16,34|-21,9|-6,34|-1,9|-18,79|-18,59|-6,79|-1,59">
@johanvergeer
johanvergeer / README.md
Last active January 31, 2021 12:45
Toggle between presentation and coding mode in VS Code using Settings Cycler plugin
@johanvergeer
johanvergeer / iterm-setup.md
Last active February 4, 2020 14:14
My iTerm setup

This Gist describes how I setup iTerm

Basic setup

  1. Install Homebrew
  2. Install oh-my-zsh
  3. ssh-keygen

Powerlevel10K

// Create a component, which is global and can be used anywhere
// in the application
const Hello = Vue.component(
'Hello', // Name of the component
{ templdate: '<span>Hello</span>' } // Options object, which contains a template
)
new Vue({
template: '<div><Hello/> there</div>', // Hardcoded 'Hello' is replated with the component
el: '#app'
@johanvergeer
johanvergeer / Program.cs
Last active May 27, 2019 19:14
Check for 10 million Guids whether they are a UUID version 4. This Gist is used in my blog post https://johanvergeer.github.io/posts/net-guid-uuid-version
/// <summary>
/// Simple script to check whether a C# Guid is really a UUID version 4.
/// </summary>
class Program
{
static void Main(string[] args)
{
Console.WriteLine($"{"Current",-10}{"Errors found",-10}");
Console.WriteLine($"{"-------",-10}{"------------",-10}");
@johanvergeer
johanvergeer / Startup.ConfigureServices.cs
Last active May 21, 2019 19:39
An ASP.NET Core 2 Server test fixture for xUnit
public void ConfigureServices(IServiceCollection services)
{
var connectionString = Configuration.GetConnectionString("ApiTestsDbContext");
services.AddDbContext<PersonDbContext>(options =>
options.UseSqlServer(connectionString));
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddScoped<IPersonRepository, PersonRepository>();
}
[Fact]
public void Post_PersonWithoutName_PersonNotSaved()
{
// Create new person, without a name, which will not be accepted by the controller
var person = new Person();
// Create new controller with mock repository
var controller = new PersonController(this._repository.Object);
// Call controller to post person
@johanvergeer
johanvergeer / PersonControllerSpec.Post_Person_PersonSaved.cs
Created May 19, 2019 14:50
Post Person object to PersonController
[Fact]
public void Post_Person_PersonSaved()
{
// Create person to post to controller
var person = new Person {Name = "Johan", Age = 37};
// Create new controller with mock repository
var controller = new PersonController(this._repository.Object);
// Call controller to post person