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,
{
"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
@maxdemarzi
maxdemarzi / data.cypher
Created August 17, 2019 05:06
Cypher Scripts for Neo4j Fraud Blog Post
CREATE (john:User {name:"John"})
CREATE (sheila:User {name:"Sheila"})
CREATE (robert:User {name:"Robert"})
CREATE (karen:User {name:"Karen"})
CREATE (m1:Merchant {name:"Computer Store"})
CREATE (m2:Merchant {name:"Gas Station"})
CREATE (m3:Merchant {name:"Jewelry Store"})
CREATE (m4:Merchant {name:"Furniture Store"})
CREATE (m5:Merchant {name:"Optometrist"})
CREATE (m6:Merchant {name:"Coffee Shop"})
@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
package com.maxdemarzi.models;
import humanize.Humanize;
import lombok.Data;
import org.jooby.Upload;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;