Skip to content

Instantly share code, notes, and snippets.

@staff0rd
staff0rd / Controller.cs
Created Sep 24, 2020
local-amazon-s3-05
View Controller.cs
public async Task<IActionResult> Upload([FromServices] IAmazonS3 s3)
{
await new TransferUtility(s3)
.UploadAsync(source, "my-bucket", "some/path/image.jpg");
return Ok();
}
@staff0rd
staff0rd / Startup.cs
Created Sep 24, 2020
local-amazon-s3-04
View Startup.cs
services
.AddSingleton<IAmazonS3>(p => {
var config = new AmazonS3Config
{
RegionEndpoint = RegionEndpoint.USWest2,
};
if (p.GetService<IHostEnvironment>().IsDevelopment())
{
config.ForcePathStyle = true;
config.ServiceURL = options.Url;
@staff0rd
staff0rd / Startup.cs
Created Sep 24, 2020
local-amazon-s3-03
View Startup.cs
if (p.GetService<IHostEnvironment>().IsDevelopment())
{
config.ForcePathStyle = true;
config.ServiceURL = "http://localhost:4566";
}
@staff0rd
staff0rd / Startup.cs
Created Sep 24, 2020
local-amazon-s3-02
View Startup.cs
services
.AddSingleton<IAmazonS3>(p => {
var config = new AmazonS3Config
{
RegionEndpoint = RegionEndpoint.USWest2,
};
return new AmazonS3Client(myAccessKey, mySecret, config);
});
View docker-compose.yml
version: '3.2'
services:
localstack:
image: localstack/localstack:latest
container_name: localstack
ports:
- 4566:4566
environment:
- SERVICES=s3
- DEBUG=1
@staff0rd
staff0rd / azure-pipeline.yaml
Created Sep 23, 2020
A Salesforce pipeline in Azure DevOps
View azure-pipeline.yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- task: sfpwowerscript-installsfdx-task@5
displayName: Install SFDX
View gist:e0abf53cf15e2b0aad8190dafbdc293f
$ ls -lh ~/nostalgia_data
total 140K
-rw-r--r-- 1 root root 0 Feb 17 09:26 __init__.py
drwxr-xr-x 3 root root 96 Feb 16 07:34 __pycache__
drwxr-xr-x 4 root root 128 Feb 17 11:00 cache
dr-------- 2 root root 64 Feb 17 09:32 dfs
drwxr-xr-x 467 root root 15K Feb 17 20:29 html
-rw-r--r-- 1 root root 112K Feb 17 20:29 meta.jsonl
-rw-r--r-- 1 root root 154 Feb 16 07:18 nostalgia_entry.py
View config (without http)
global:
scrape_interval: 30s
scrape_timeout: 10s
evaluation_interval: 30s
external_labels:
prometheus: monitoring/kube-prometheus
prometheus_replica: prometheus-kube-prometheus-0
alerting:
alert_relabel_configs:
- separator: ;
View config
global:
scrape_interval: 30s
scrape_timeout: 10s
evaluation_interval: 30s
external_labels:
prometheus: monitoring/kube-prometheus
prometheus_replica: prometheus-kube-prometheus-0
alerting:
alert_relabel_configs:
- separator: ;
View iterateWithIndex.cs
var collection = Enumerable.Repeat<Comparison>(new Comparison(), 5).ToList();
var items = Enumerable.Range(0, collection.Count).Zip(collection, (a, b) => new { Index = a, Value = b });
foreach(var item in items)
{
DoSomething(item.Value, item.Index);
}
for(var i = 0; i < collection.Count; i++)