Skip to content

Instantly share code, notes, and snippets.

View leandroribeiro's full-sized avatar
🎯
Focusing

Leandro Ribeiro leandroribeiro

🎯
Focusing
View GitHub Profile
@leandroribeiro
leandroribeiro / cors-test.ps1
Created March 15, 2024 13:56
Testando CORS através do PowerShell
$response = Invoke-WebRequest -Uri "https://#FILL_TARGET_HERE#" -Method Options -Headers @{
"Origin" = "https://#FILL_ORIGIN_HERE#"
"Access-Control-Request-Method" = "GET"
"Access-Control-Request-Headers" = "Authorization"
"Accept" = "application/json"
} -UseBasicParsing
$color = "Red"
$headers = $response.Headers | ConvertTo-Json
if ($headers -match "Access-Control-Allow-Origin") {
@leandroribeiro
leandroribeiro / invoke.ps1
Created March 14, 2024 14:02
Serverless Invoke using file data
$token = $args[0]
$original_dir = Get-Location
Set-Location ..
(Get-Content "$original_dir\event.json" -Raw) -replace "#TOKEN#", $token | Set-Content "$original_dir\event.tmp.json"
serverless invoke --function validateToken --path "$original_dir\event.tmp.json" --config .\serverless.yml --log
Remove-Item "$original_dir\event.tmp.json"
@leandroribeiro
leandroribeiro / create-bucket.sh
Created March 7, 2024 12:31
Create S3 Bucket with AWS CLI
# by parameter
# bucketName=$1
# fixed value
bucketName=cw.sa-east-1.syn-results
# Create the bucket
aws s3api create-bucket --bucket ${bucketName} --region your-region
# Enable server-side encryption
@leandroribeiro
leandroribeiro / canary.yml
Created March 6, 2024 13:27
Amazon CloudWatch Synthetics Canary - Cloud Formation Sample
CloudWatchSyntheticsRole:
Type: AWS::IAM::Role
Properties:
RoleName: ${self:service}-${self:provider.region}-ExecutionRole
Description: CloudWatch Synthetics lambda execution role for running canaries
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
@leandroribeiro
leandroribeiro / main.cs
Created August 13, 2021 14:52
C# - Prevent Sleep on Windows v2
using System;
using System.Threading;
using System.Runtime.InteropServices;
// reference http://eddiejackson.net/lab/2020/03/02/c-prevent-sleep-on-windows-v2/
namespace SleepControl
{
class Program
@leandroribeiro
leandroribeiro / main.cs
Last active August 13, 2021 14:53
C# - Prevent Sleep on Windows v1
using System;
using System.Runtime.InteropServices;
namespace DisableSleepMode
{
class Program
{
// Sleep Control
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
@leandroribeiro
leandroribeiro / Dockerfile
Last active March 5, 2024 09:30
Docker Compose and Dockerfile to build and publish .NET Full Framework Sample WebAPI ASP.NET 4.8
# escape=`
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS builder
WORKDIR /app
COPY API1/. .
RUN nuget restore -PackagesDirectory ../packages
# RUN msbuild API1.csproj /p:OutputPath=c:\out `
# /t:restore
RUN msbuild API1.csproj /p:Configuration=Debug `
/p:DeployOnBuild=True `
/p:DeployDefaultTarget=WebPublish `
@leandroribeiro
leandroribeiro / gist:9e46b50235ad4e93eeb97f6eb576a0bb
Created May 7, 2018 17:16
.NET Core Memory Cache Simple Demo 01
try
{
var provider = new ServiceCollection()
.AddMemoryCache()
.BuildServiceProvider();
//And now?
var cache = provider.GetService<IMemoryCache>();
using (var entry = cache.CreateEntry("item2"))
@leandroribeiro
leandroribeiro / evernote-dark.css
Created April 1, 2018 00:58
Evernote Dark Mode 201803
div#gwt-debug-NoteView-root,
div#gwt-debug-NoteTitleView-container,
img.en-media
{
filter: invert(.9)
}
body,
div#gwt-debug-sidebar,
div#gwt-debug-NotebookHeader-container
{
@leandroribeiro
leandroribeiro / WebConfig-Live-Transformations.xml
Last active February 10, 2017 18:47
Transform web.config on build with custom targets
<!-- More read here: https://msdn.microsoft.com/en-us/library/ms366724.aspx -->
<!-- First, we extend the "BuildDependsOn" property with our custom target for applying the transform.
This is a cleaner/safer alternative to overloading the "AfterBuild" target: -->
<PropertyGroup>
<BuildDependsOn>
$(BuildDependsOn);
_VisualStudioApplyTransform;
</BuildDependsOn>
</PropertyGroup>