Skip to content

Instantly share code, notes, and snippets.

View maxdemarzi's full-sized avatar
🏠
Working from home

Max De Marzi maxdemarzi

🏠
Working from home
View GitHub Profile
@maxdemarzi
maxdemarzi / connected-components-bfs.cpp
Created May 26, 2022 15:16 — forked from Ch-sriram/connected-components-bfs.cpp
Count Number of Connected Components [TC: O(V+E); SC: O(V+E)]
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
void addEdge(vector<int> *adj, int u, int v) {
adj[u].push_back(v);
adj[v].push_back(u);
}
@maxdemarzi
maxdemarzi / hello_julia.lua
Created April 7, 2022 05:49 — forked from ihnorton/hello_julia.lua
Calling Julia from LuaJIT via a shared library
ffi = require("ffi")
julia = ffi.load("/Users/inorton/git/julia/usr/lib/libjulia.dylib", true)
ffi.cdef[[
void jl_eval_string(const char*);
void jl_init(const char*);
]]
julia.jl_init("/Users/inorton/git/julia/usr/lib/")
julia.jl_eval_string(" println(\"hello, world\") ")
-- should print "hello, world"
#include <fstream>
#include <scripting/ModException.hpp>
#include <sanity.hpp>
#include "LuaSecurity.hpp"
using namespace scripting;
namespace {
void copyAll(sol::environment &env, const sol::global_table &globals,
@maxdemarzi
maxdemarzi / __usage.adoc
Last active December 8, 2021 10:49 — forked from jexp/__numbers_31.txt
Concurrent Neo4j Performance Tests via HTTP + Cypher (usage: ./_run_ab.sh 4 10000 create_plain.json)

Usage

Use latest Neo4j for best results, e.g. 2.2.2 or 2.3.0-M02 (http://neo4j.com/download) On a machine with 12 cores use concurrency 24

Create 1 node, 1 rel, 1 property per request, 1M requests

Total: 1M nodes, rels, props


@maxdemarzi
maxdemarzi / bom.cypher
Last active March 9, 2021 16:21
Bill of Materials sample data
CREATE (f1:Family {id:'f1'})
CREATE (f2:Family {id:'f2'})
CREATE (f3:Family {id:'f3'})
CREATE (a1:Asset {id:'a1'})
CREATE (a2:Asset {id:'a2'})
CREATE (a3:Asset {id:'a3'})
CREATE (a4:Asset {id:'a4'})
CREATE (a5:Asset {id:'a5'})
CREATE (a6:Asset {id:'a6'})
CREATE (a7:Asset {id:'a7'})
@maxdemarzi
maxdemarzi / exercise-1.query.cypher
Last active February 14, 2021 18:46
Modeling Cypher Exercise 1 and 2
MATCH (company)<-[:WORKS_FOR]-(me:Person{username:'ian'})-[:HAS_SKILL]->(skill),
(company)<-[:WORKS_FOR]-(colleague)-[r:HAS_SKILL]->(skill)
WHERE r.level > 1
RETURN colleague.username AS username,
count(skill) AS score,
collect(skill.name) AS skills
ORDER BY score DESC
{
"options": {
"generate_report": true,
"verbose": true,
"report_file_location": "purged_css_report_data.json"
}
}
@maxdemarzi
maxdemarzi / queries.cypher
Last active March 20, 2020 01:50
Cypher Queries for Finding Fraud Part 2 Revisited
WITH ["Jennifer","Michelle","Tanya","Julie","Christie",
"Sophie","Amanda","Khloe","Sarah","Kaylee"] AS names
FOREACH (r IN range(1,1000000) |
CREATE (:User {username:names[r % size(names)] + "-" + r}) );
FOREACH (r IN range(1,1000000) | CREATE (:Account {number: r, balance: round(rand() * 1000000) / 100.0, type:"Savings"}))
UNWIND range(1,1000000) AS number
MATCH (user), (account)
@maxdemarzi
maxdemarzi / cypher.txt
Created September 11, 2019 09:25
Real Property Graph
Schema
------
CREATE CONSTRAINT ON (n:Location) ASSERT n.id IS UNIQUE;
CREATE CONSTRAINT ON (n:Owner) ASSERT n.name IS UNIQUE;
CREATE INDEX ON :Address(addr, zip);
Data Exploration
@maxdemarzi
maxdemarzi / collect.cypher
Created August 19, 2019 18:40
Fighting Fraud with Neo4j part 2
MATCH (n:User)
RETURN n.partition, COUNT(*) AS members, COLLECT(n.name) AS names
ORDER BY members DESC
LIMIT 10