Skip to content

Instantly share code, notes, and snippets.

@Layoric
Layoric / main.cs
Last active September 1, 2016 02:31
Auto mapping
using System;
using ServiceStack;
using ServiceStack.Text;
public class GetPersonResponse
{
public string FirstName { get;set; }
public string LastName { get;set; }
public int Age { get;set; }
}
@Layoric
Layoric / main.cs
Last active September 1, 2016 02:45
New Public Gist
using System;
using ServiceStack;
using ServiceStack.Text;
public class GetPersonResponse
{
public string FirstName { get;set; }
public string LastName { get;set; }
public int Age { get;set; }
public string PostCode { get;set; }
@Layoric
Layoric / ec2-startup.sh
Created September 13, 2016 06:30 — forked from ReedD/ec2-startup.sh
User data for EC2 to set up Docker and Compose (Fig) for ec2-user
#!/bin/sh
export PATH=/usr/local/bin:$PATH;
yum update
yum install docker -y
service docker start
# Docker login notes:
# - For no email, just put one blank space.
# - Also the private repo protocol and version are needed for docker
# to properly setup the .dockercfg file to work with compose
@Layoric
Layoric / main.cs
Last active September 30, 2016 08:21
LoadSelect Example
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.OrmLite;
using ServiceStack.OrmLite.Sqlite;
using ServiceStack.DataAnnotations;
var dbFactory = new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider);
var db = dbFactory.Open(); // Open ADO.NET DB Connection
public class Foo
@Layoric
Layoric / step-by-step-gatling-idea.md
Last active December 12, 2016 23:29 — forked from groovybayo/step-by-step-gatling-idea.md
Gatling: Step by step guide to IntelliJ integration

Step by step guide to setting up IDEA to write gatling simulations

Prerequisites:

Have [SBT plugin][sbt-plugin] installed

Begin

  • [Create a new project][create-project] in IDEA ( File > New Project ...)
    • Make sure you select a maven module
@Layoric
Layoric / solcast_client_example.py
Last active February 26, 2017 04:59
Example solcast-py API usage.
import solcast
# Fetch latest PV power forecast
pv_power_resp = solcast.get_pv_power_forecasts(-35, 149, capacity=2000, tilt=23, azimuth=0, api_key='INSERTYOURAPIKEYHERE')
# Print soonest PV power forecast
print(pv_power_resp.forecasts[0]['pv_estimate'])
Create an application that:
1. Loops 100 times
2. Pauses for 200ms each loop
3. Writes 'Fizz' to the console when loop count is divisable by 2
4. Writes 'Buzz' to the console when loop count is divisable by 5
5. Writes 'FizzBuzz' to the console when loop count is divisable by both
Extra
Setup project to write a unit test using NUnit, walk through project steps you need to enable this.
@Layoric
Layoric / main.cs
Created August 27, 2019 03:03
SS enum example
using System.Linq;
using System;
using ServiceStack;
using ServiceStack.Text;
public enum Foo
{
None,
Test,
Bar
@Layoric
Layoric / AppHost.cs
Last active June 2, 2021 06:12
Register AutoQuery Plugin
// Connect your database
container.AddSingleton<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider));
// Configure AutoQuery to Generate CRUD services
Plugins.Add(new AutoQueryFeature {
MaxLimit = 1000,
GenerateCrudServices = new GenerateCrudServices {
AutoRegister = true
}
@Layoric
Layoric / AppHost.cs
Last active June 2, 2021 06:15
autoquery-custom
// Connect your database
container.AddSingleton<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider));
// Add the AutoQuery Plugin
Plugins.Add(new AutoQueryFeature { MaxLimit = 100 });