Skip to content

Instantly share code, notes, and snippets.

View scattered-code's full-sized avatar
🏠
Working from home / Living at work

Alexandru Puiu scattered-code

🏠
Working from home / Living at work
View GitHub Profile
Time it took to process sequentially: 87601 ms.
Time it took to process using await foreach (C# 8.0): 96101 ms.
Time it took to process using ForEachAsync: 5210 ms.
Time it took to process using ParallelForEachAsync: 5135 ms.
Time it took to process using AsyncParallelForEach with IEnumerable: 4345 ms.
Time it took to process using AsyncParallelForEach with IAsyncEnumerable: 4301 ms.
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
AMD Ryzen Threadripper 2950X, 1 CPU, 32 logical and 16 physical cores
.NET Core SDK=3.1.100
[Host] : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
DefaultJob : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
| Method | Mean | Error | StdDev | Ratio | RatioSD |
|------------------------------- |---------:|---------:|---------:|------:|--------:|
| Linear | 22.599 s | 0.4394 s | 0.5866 s | 1.00 | 0.00 |
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
AMD Ryzen Threadripper 2950X, 1 CPU, 32 logical and 16 physical cores
.NET Core SDK=3.1.100
[Host] : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
Job-WEHRKA : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
InvocationCount=1 UnrollFactor=1
| Method | Mean | Error | StdDev | Ratio | RatioSD |
|------------------------------- |---------:|--------:|--------:|------:|--------:|
// First let's find all the users active during that time that have passed through that router on a Tuesday between 10 and 11PM
MATCH (u:User)->[appusage:USED_APPLICATION]->(app:Application)->[:DEPLOYED_ON]->(:VirtualMachine)->[:HOSTED_ON]->(host:Host)->[:CONNECTED_TO]->(r1:Router)->[:ROUTES_TO]->(internet:Internet)
WHERE datetime(appusage.date).dayOfWeek == 2 AND datetime(appusage.date).hour == 22 AND r.name == "NY2"
WITH collect(u.email) as usersRouter1
MATCH (u)->[appusage]->(app)->[:DEPLOYED_ON]->(:VirtualMachine)->[:HOSTED_ON]->(host)->[:CONNECTED_TO]->(r2:Router)->[:ROUTES_TO]->(internet)
WHERE NOT(r1=r2)
WITH collect(u.email) as usersRouter2
RETURN [x in usersRouter1 WHERE not(x in usersRouter2)] as affectedUsers
choco install neo4j-community -packageParameters "/Install:C:\Apps\Neo"
yum install neo4j
apt-get install neo4j
MATCH (n)<-[:DEPENDS_ON*]-(dependent)
RETURN n.host as Host,
count(DISTINCT dependent) AS Dependents
ORDER BY Dependents DESC
LIMIT 1
CREATE INDEX ON :VM(hostname);
CREATE INDEX ON :Datacenter(name);
CREATE INDEX ON :OperatingSystem(name);
LOAD CSV WITH HEADERS FROM 'file:///vm.csv' AS data
WITH data WHERE data.hostname IS NOT NULL
MERGE (vm:VM {hostname: data.hostname}) SET vm.memory = round(toFloat(data.memory)/1024/1024/1024) + " GB", vm.last_updated = data.last
MERGE (dc:Datacenter { name: data.dc })
MERGE (os:OperatingSystem { name: data.os })
MERGE (vm)-[:IS_IN]->(dc)
MERGE (vm)-[:USES_OPERATING_SYSTEM]->(os)
CALL apoc.load.json("https://onodo.org/api/visualizations/21/nodes/") yield value
CREATE (n:Person) set n+=value
WITH count(*) as nodes
CALL apoc.load.json("https://onodo.org/api/visualizations/21/relations/") yield value
MATCH (a:Person {id:value.source_id})
MATCH (b:Person {id:value.target_id})
CALL apoc.create.relationship(a,value.relation_type,{},b) yield rel
RETURN nodes, count(*) as relationships
...
FOREACH (ignoreMe in CASE WHEN data.Company <> "" THEN [1] ELSE [] END |
MERGE (organization: Organization { name: data.Company })
MERGE (user)-[:IN_ORGANIZATION]->(company)
)
CALL dbms.security.createUser("elastic", "f@ncy9a$$w0rd", false)