Skip to content

Instantly share code, notes, and snippets.

Avatar

Darren Reid Layoric

View GitHub Profile
@Layoric
Layoric / mix.md
Last active Sep 21, 2022 — forked from gistlyn/mix.md
Mix Gists
View mix.md

Available Gists

Projects

  • console-cs {to:'.'} project,C# C# .NET 6 Console App
  • console-fs {to:'.'} project,F# F# .NET 6 Console App
  • console-vb {to:'.'} project,VB VB .NET 6 Console App
  • console-ss {to:'.'} project,S# #Script Console App
  • console-lisp {to:'.'} project,Lisp #Script Lisp Console App
  • init {to:'.'} project,C# Empty .NET 6 ServiceStack App
@Layoric
Layoric / DiscordAuthProvider.cs
Last active Sep 14, 2021
Discord OAuth2 provider for ServiceStack
View DiscordAuthProvider.cs
/// <summary>
/// Create an OAuth2 App at: https://discord.com/developers/applications
/// The Apps Callback URL should match the CallbackUrl here.
/// Discord OAuth2 info: https://discord.com/developers/docs/topics/oauth2
/// Discord OAuth2 Scopes from: https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes
/// email: Basic info, plus will return email info from /users/@me API, this is the minimum required for ServiceStack
/// integration.
///
/// Checking of email verification is enforced due to Discord not requiring verified emails.
///
View on-startup.sh
#!/bin/bash
set -e
wget https://download.visualstudio.microsoft.com/download/pr/8468e541-a99a-4191-8470-654fa0747a9a/cb32548d2fd3d60ef3fe8fc80cd735ef/dotnet-sdk-5.0.302-linux-x64.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/50687c84-e120-4410-bd4a-b1e0869d03f4/6038576259f95ef61d4d103ee3967130/dotnet-runtime-5.0.8-linux-x64.tar.gz
mkdir -p /home/ec2-user/dotnet && tar zxf dotnet-runtime-5.0.8-linux-x64.tar.gz -C /home/ec2-user/dotnet
export DOTNET_ROOT=/home/ec2-user/dotnet
export PATH=$PATH:/home/ec2-user/dotnet
export DOTNET_CLI_HOME=/home/ec2-user/dotnet
export HOME=/home/ec2-user
@Layoric
Layoric / Customers.cs
Last active Jun 2, 2021
autoquery-min-code-first
View Customers.cs
[Route("/customers")]
public class QueryCustomers : QueryDb<Customer> {}
@Layoric
Layoric / AppHost.cs
Created Jun 2, 2021
autoquery-just-apphost
View AppHost.cs
// Connect your database
container.AddSingleton<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider));
// Add the AutoQuery Plugin
Plugins.Add(new AutoQueryFeature { MaxLimit = 100 });
@Layoric
Layoric / AppHost.cs
Last active Jun 2, 2021
autoquery-custom
View AppHost.cs
// Connect your database
container.AddSingleton<IDbConnectionFactory>(c =>
new OrmLiteConnectionFactory(MapProjectPath("~/northwind.sqlite"), SqliteDialect.Provider));
// Add the AutoQuery Plugin
Plugins.Add(new AutoQueryFeature { MaxLimit = 100 });
@Layoric
Layoric / AppHost.cs
Last active Jun 2, 2021
Register AutoQuery Plugin
View AppHost.cs
// 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 / main.cs
Created Aug 27, 2019
SS enum example
View main.cs
using System.Linq;
using System;
using ServiceStack;
using ServiceStack.Text;
public enum Foo
{
None,
Test,
Bar
View fizzbuzz.txt
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 / solcast_client_example.py
Last active Feb 26, 2017
Example solcast-py API usage.
View solcast_client_example.py
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'])