Scrapes data from https://www.myedenred.pt/ into a csv file
run with dotnet test
var data = Parse(@"https://raw.githubusercontent.com/dssg-pt/covid19pt-data/master/data.csv", | |
v => new | |
{ | |
data = DateTime.Parse(v["data"]), | |
novos_total = decimal.Parse(v["confirmados"]), | |
novos = decimal.Parse(v["confirmados_novos"]) | |
}); | |
var amostras = Parse(@"https://raw.githubusercontent.com/dssg-pt/covid19pt-data/master/amostras.csv", | |
v => new | |
{ |
set clipboard=unnamed "Use System clipboard | |
set autoindent "New lines inherit the indentation of previous lines | |
set expandtab "Convert tabs to spaces. | |
set smarttab "Insert 'tabstop' number of spaces when the 'tab' key is pressed. | |
set tabstop=4 "Indent using four spaces. | |
set shiftwidth=4 | |
set hlsearch "Enable search highlighting. | |
set incsearch "Incremental search that shows partial matches. | |
set smartcase "Automatically switch search to case-sensitive when search query contains an uppercase letter. |
using System.ComponentModel; | |
// Uses cake Configuration to bind a model | |
// Configuration values should come from | |
// 1 - CAKE_ prefixed env vars | |
// 2 - cake.config files | |
// 3 - cmdline arguments | |
class NaiveModelBinder | |
{ | |
private readonly Func<string, string> getValue; |
using System; | |
using System.IO; | |
using System.Xml.Serialization; | |
using Xunit.Abstractions; | |
public abstract class SerializableTestCase : IXunitSerializable | |
{ | |
/// <inheritdoc/> | |
public void Deserialize(IXunitSerializationInfo info) | |
{ |
$certPath = ".\seq\Certificates\443.pem" | |
$needNewCert = if (Test-Path $certPath) { | |
$cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath) | |
#should return true if cert is expired | |
$cert.NotAfter -lt (Get-Date) | |
} else { | |
$true | |
} | |
# download certificates if needed | |
if ($needNewCert) { |
Scrapes data from https://www.myedenred.pt/ into a csv file
run with dotnet test
public class DesignTimeFactory : IDesignTimeDbContextFactory<MyDbContext> | |
{ | |
public MarketDataServiceDbContext CreateDbContext(string[] args) | |
=> new MyDbContext(new DbContextOptionsBuilder<MyDbContext>().UseSqlServer(args[0]).Options); | |
} |
function otp($SECRET="ABCDEFGHIJKLMNOP", $LENGTH=6, $WINDOW=30){ | |
$span = (New-TimeSpan -Start (Get-Date -Year 1970 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0) -End (Get-Date).ToUniversalTime()).TotalSeconds | |
$unixTime = [Convert]::ToInt64([Math]::Floor($span/$WINDOW)) | |
$timeBytes = [BitConverter]::GetBytes($unixTime) | |
[array]::Reverse($timeBytes) | |
$enc = [System.Text.Encoding]::UTF8 | |
$hmac = New-Object -TypeName System.Security.Cryptography.HMACSHA1 | |
$hmac.key = Convert-Base32ToBytes($SECRET.ToUpper()) | |
$randHash = $hmac.ComputeHash($timeBytes) |
using System.Threading; | |
using System.Threading.Channels; | |
using System.Threading.Tasks; | |
class Processor<T> where T : class | |
{ | |
private readonly Channel<T> _channel = Channel.CreateUnbounded<T>(); | |
private readonly Task processors; | |
public Processor(Func<T, Task> action, int numberOfConsumers = 4) |
public class DataPipeline<T> | |
{ | |
private static ExecutionDataflowBlockOptions Options => new() { BoundedCapacity = 1 }; | |
private readonly IReceivableSourceBlock<T> sourceBlock; | |
public DataPipeline(IReceivableSourceBlock<T> sourceBlock) => this.sourceBlock = sourceBlock; | |
public Task Completion => sourceBlock.Completion; | |
public IAsyncEnumerable<T> ReceiveAllAsync(CancellationToken ct = default) => sourceBlock.ReceiveAllAsync(ct); | |
public DataPipeline<TOut> Activity<TOut>(Func<T, Task<TOut>> action) => Link(new TransformBlock<T, TOut>(action, Options)); |