Skip to content

Instantly share code, notes, and snippets.

View yfarjoun's full-sized avatar

Yossi Farjoun yfarjoun

View GitHub Profile
@yfarjoun
yfarjoun / maximal_cliques.py
Created August 21, 2018 03:12 — forked from abhin4v/maximal_cliques.py
Finds all maximal cliques in a graph using the Bron-Kerbosch algorithm
# Finds all maximal cliques in a graph using the Bron-Kerbosch algorithm. The input graph here is
# in the adjacency list format, a dict with vertexes as keys and lists of their neighbors as values.
# https://en.wikipedia.org/wiki/Bron-Kerbosch_algorithm
from collections import defaultdict
def find_cliques(graph):
p = set(graph.keys())
r = set()
x = set()
A
B
C
D
E
F
G
H
I
J
@yfarjoun
yfarjoun / stop_notebook_env.sh
Last active October 21, 2022 15:10
Stopping a Terra notebook environment from within it
curl -X "POST" \
-H 'accept: application/json' \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
"https://notebooks.firecloud.org/api/google/v1/runtimes/$GOOGLE_PROJECT/$CLUSTER_NAME/stop"
@yfarjoun
yfarjoun / coord_cartesian_panels.R
Created December 4, 2022 18:23 — forked from r2evans/coord_cartesian_panels.R
per-facet panel range clipping
#' Cartesian coordinates per facet-panel
#'
#' This function mimics the behavior of [ggplot2::coord_cartesian()],
#' while supporting per-panel limits when faceted.
#'
#' @details
#'
#' A 'panel_limits' data frame may contain:
#'
#' - zero or more faceting variables, all of which must be found
# instead of doing sort | uniq -c this will count with little overhead the various lines that you sent at it
awk '{table[$0]+=1} END {for (entry in table) {print entry, table[entry]}}'