Scrapes data from https://www.myedenred.pt/ into a csv file
run with dotnet test
| 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)); |
| 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) |
| 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) |
| public class DesignTimeFactory : IDesignTimeDbContextFactory<MyDbContext> | |
| { | |
| public MarketDataServiceDbContext CreateDbContext(string[] args) | |
| => new MyDbContext(new DbContextOptionsBuilder<MyDbContext>().UseSqlServer(args[0]).Options); | |
| } |
Scrapes data from https://www.myedenred.pt/ into a csv file
run with dotnet test
| $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) { |
| using System; | |
| using System.IO; | |
| using System.Xml.Serialization; | |
| using Xunit.Abstractions; | |
| public abstract class SerializableTestCase : IXunitSerializable | |
| { | |
| /// <inheritdoc/> | |
| public void Deserialize(IXunitSerializationInfo info) | |
| { |
| 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; |
| 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. |