Skip to content

Instantly share code, notes, and snippets.

View jexp's full-sized avatar
🐉
Watching the chamaeleon.

Michael Hunger jexp

🐉
Watching the chamaeleon.
View GitHub Profile
@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@dcode
dcode / GitHub Flavored Asciidoc (GFA).adoc
Last active April 20, 2024 13:55
Demo of some useful tips for using Asciidoc on GitHub

GitHub Flavored Asciidoc (GFA)

@jexp
jexp / bsky_jazco_import.cypher
Last active May 8, 2023 09:30
BlueSky User Interactions Neo4j Import, data collection courtesy https://bsky.jazco.dev/
create constraint user_key if not exists for (u:User) require (u.key) is unique;
// add nodes
call apoc.load.json("https://bsky.jazco.dev/exported_graph_minified.json","$.nodes")
yield value as nv
call { with nv
merge (n:User {key:nv.key})
on create set n += apoc.map.clean(nv.attributes,["key"],[])
} in transactions of 10000 rows;
@ikwattro
ikwattro / GithubEventAnalysisWithNeo4j.markdown
Last active December 2, 2022 17:49
Github Events Analysis with Neo4j

Github Events Analysis with Neo4j

Imgur

On July 22, Github announced the 3rd Annual Github Data Challenge presenting multiple sources of data available.

This sounded to me a good opportunity to use their available data and import it in Neo4j in order to have a lot of fun at analyzing the data that fits naturally in a graph.

As I work mainly offline or behind military proxies that do not permit me to use the ReST API, I decided to go for the Github Archive available here, you can then download json files representing Github Events on a daily/hour basis.

@wagenrace
wagenrace / load_gi50.cypher
Created April 8, 2022 06:47
Loading the GI50 of NCI60 into neo4j
// CSV file can be downloaded here:
// https://wiki.nci.nih.gov/download/attachments/147193864/GI50.zip?version=2&modificationDate=1649214698000&api=v2
LOAD CSV WITH HEADERS FROM 'file:///GI50.csv' AS row
MERGE (chem:Chemical {nsc: toInteger(row.NSC)})
MERGE (cell:CellLine {name: row.CELL_NAME})
MERGE (dis:Disease {name: row.PANEL_NAME})
WITH chem, cell, dis, row
MERGE (chem)-[:GI50 {concentration: row.AVERAGE, research: "NCI60", unit: row.CONCENTRATION_UNIT, experiment_id: row.EXPID, count: row.COUNT}]->(cell)
MERGE (cell)-[:CELL_LINE_OF]->(dis);
@aseemk
aseemk / neo4j-cypher-weighted-followers.md
Last active March 21, 2022 13:54
Neo4j Cypher query to get a "normalized" or "weighted" follower count in a social graph.

This is a Neo4j 1.9 (pre-2.0) query:

START user=node:nodes(type='user')
MATCH user <-[:follows]- follower -[?:follows]-> other
WITH user, follower, 1.0 / COUNT(other) AS weighted
WITH user, COUNT(follower) AS numFollowers, SUM(weighted) as totalWeighted
RETURN user, numFollowers,
  ROUND(totalWeighted * 100) / 100.0 AS totalWeighted,
 ROUND(totalWeighted * 100 / numFollowers) / 100.0 AS avgFollowerWeight
CREATE CONSTRAINT word_name IF NOT EXISTS ON (w:Word) ASSERT w.name IS UNIQUE;
CREATE CONSTRAINT cap_idx_char IF NOT EXISTS FOR (cap:CharAtPos) REQUIRE (cap.idx, cap.char) IS NODE KEY;
LOAD CSV FROM
"https://gist.githubusercontent.com/jexp/b1882301adb95a8015d6c29d3e24e341/raw/6fe6ac31b9ed46900451e17b5215e9088ec09a6e/wordle.csv" as row
MERGE (w:Word {name:row[0]});
:auto MATCH (w:Word)
CALL { WITH w
@jexp
jexp / ms-concepts-import.sh
Created November 4, 2016 02:32
Load and query the Microsoft Concept Graph in Neo4j https://concept.research.microsoft.com/Home/Introduction
function import_extract_first {
echo "name:ID(Concept)" > concepts.txt
cat data-concept-instance-relations.txt | cut -d $'\t' -f 1 | sort | uniq >> concepts.txt
echo "name:ID(Instance)" > instances.txt
cat data-concept-instance-relations.txt | cut -d $'\t' -f 2 | sort | uniq >> instances.txt
echo $':END_ID(Concept)\t:START_ID(Instance) relations:int' > is_a.hdr
$NEO4J_HOME/bin/neo4j-import --into concepts.db --id-type string --delimiter TAB --bad-tolerance 13000000 --skip-duplicate-nodes true --skip-bad-relationships true \
@jexp
jexp / 01-load.cypher
Last active July 6, 2021 09:44
Wahlomat Daten Sachsen Anhalt 2021
create index on :Partei(name);
create index on :These(name);
create constraint if not exists on (p:Partei) assert p.id is unique;
create constraint if not exists on (t:These) assert t.id is unique;
load csv with headers from
"https://gist.github.com/jexp/189e9d7a47095ff96ff522fe350f0d36/raw/fa2f356514ec981067856ad7a5f6dfb017122c8d/wom-sa-2021.csv"
as row
merge (p:Partei {id:toInteger(row.`Partei: Nr.`)}) on create set p.text = row.`Partei: Name`, p.name = row.`Partei: Kurzbezeichnung`