Skip to content

Instantly share code, notes, and snippets.

@DanielSSilva
DanielSSilva / codeCoverage.yaml
Created July 13, 2021 10:18
The tasks to install dependencies, run tests and code coverage
- task: DotNetCoreCLI@2
displayName: 'Install .NET tools from local manifest'
inputs:
command: custom
custom: tool
arguments: 'restore'
- task: DotNetCoreCLI@2
displayName: 'Run unit tests'
inputs:
@DanielSSilva
DanielSSilva / Greeter_CodeCoverage.yaml
Created July 13, 2021 10:06
Simple pipeline, with code covarege
trigger:
- none
pool:
vmImage: 'windows-latest'
jobs:
- job: Build
steps:
- task: DotNetCoreCLI@2
@DanielSSilva
DanielSSilva / greeter.yaml
Created June 28, 2021 22:07
An example of a simple YAML pipeline for a c# proj
trigger:
- none
pool:
vmImage: 'windows-latest'
jobs:
- job: Build
steps:
- task: DotNetCoreCLI@2
@DanielSSilva
DanielSSilva / setup_dotnet.sh
Created September 27, 2020 23:31
This is an adaptation from MS helper to install dependencies, but to install dotnet 3.1 only
#!/bin/bash
set -e
# Select a default .NET version if one is not specified
if [ -z "$DOTNET_VERSION" ]; then
DOTNET_VERSION=3.1.300
fi
# Install .NET as the sudo (non-root) user
sudo -i -u $SUDO_USER bash << EOF
@DanielSSilva
DanielSSilva / logExample.log
Created April 20, 2020 23:53
LogSample for blogpost
Date|LogLevel|Class|Url|Action|Method|TraceIdentifier|UserIdentity|RequestDuration|Info
2020-04-02 15:12:11.5246|INFO|Program|||||||"Starting Program"
2020-04-02 15:12:11.7616|INFO|Program|||||||"Current Version: 1.1.1 "
2020-04-02 15:31:33.0385|INFO|SomeController|http://localhost/api/users/3|GetUserDetails|GET|0HLUN2A51T7M5:00000002|7||"OnActionExecuting - Entered on the controller "
2020-04-02 15:31:33.6408|INFO|SomeController|http://localhost/api/users/3|GetUserDetails|GET|0HLUN2A51T7M5:00000002|7|573|"{""_id"": ""5e9df633a56334748e1fb801"",""guid"": ""a9c7651b-1b4b-4389-8c2c-600c767de1bf"",""isActive"": true,""name"": ""Lynn Hammond"",""gender"": ""female"",""friends"": [{""id"": 0,""name"": ""Briana Garrett""},{""id"": 1,""name"": ""Carey Mcpherson""}]}"
2020-04-02 15:31:34.7320|INFO|SomeController|http://localhost/api/users/3/friends|PostUserFriends|POST|0HLUN2A51T7M5:00000004|7||"OnActionExecuting - Entered on the controller "
2020-04-02 15:31:34.9779|INFO|SomeController|http://localhost/api/users/3/f
@DanielSSilva
DanielSSilva / light_Led.ps1
Last active March 18, 2019 00:33
Simple script that turns a led on and off each second
$ledPinNumber = 8
while($true){
Set-GpioPin -Id $ledPinNumber -Value Low
Start-Sleep -Seconds 1
Set-GpioPin -Id $ledPinNumber -Value High
Start-Sleep -Seconds 1
}
@DanielSSilva
DanielSSilva / remoteSession_helper.ps1
Created September 26, 2018 19:18
This gist a quick helper to setup the remote session for the raspberry Pi within PowerShell
# PowerShell Remoting Over SSH
https://github.com/PowerShell/PowerShell-IoT/blob/master/docs/remoting.md
(this is required because of the service sshd restart)
sudo apt-get purge openssh-server && sudo apt-get install openssh-server
sudo nano /etc/ssh/sshd_config
Enable password authentication
@DanielSSilva
DanielSSilva / error.ps1
Created May 7, 2018 08:18
The referred error might happen between line 58 and 86
function Write-Char {
param(
[ValidateLength(1,1)]
[string]$char
)
##############TEMP#################
$alphabet = @{
A = 0x3E, 0x05, 0x3E
B = 0x1F, 0x15, 0x0A
C = 0x0E, 0x11, 0x11
class Program
{
static void Main(string[] args)
{
IEnumerable<Xpto> enumerable = new List<Xpto>
{
new Xpto(15,"a"),
new Xpto(8,"c"),
new Xpto(3,"e"),
new Xpto(5,"t"),
HubConnection connection = new HubConnectionBuilder()
.WithUrl("http://localhost:52846/entryPoint")
.WithConsoleLogger()
.Build();
connection.StartAsync().GetAwaiter().GetResult();
connection.InvokeAsync("RegisterConnectionOnGroup", "CoolEmployees");
int myNumber = r.Next(0, 1000); // just to ensure that we have different clients
connection.On<string>("ClientMethod", data => Console.WriteLine($"I'm CoolEmployee with random number = {myNumber} - GOT THIS: {data}"));
while (true) ;