Skip to content

Instantly share code, notes, and snippets.

View pchtsp's full-sized avatar

Franco Peschiera pchtsp

View GitHub Profile
@pchtsp
pchtsp / Basic API call (TypeScript).EXCEL.yaml
Created January 17, 2024 13:29
Performs a basic Excel API call using TypeScript.
name: Basic API call (TypeScript)
description: Performs a basic Excel API call using TypeScript.
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Excel.run(async (context) => {
import ete3
def get_node_pos(node):
if node.up is None:
return 0
pos = node.up.children.index(node)
return pos
def post_traverse_from_node(node1, is_leaf_fn=None, node_end=None):
@pchtsp
pchtsp / get_nodes_between_nodes_in_tree.py
Created August 21, 2018 15:03
The function below takes two nodes (node1, node2) that share the same tree root (which default to the first node in the tree and the last one respectively). It then searches for nodes that are 'in between'. It also determines the order of the two nodes in the tree (which one is first and which one is second).
def get_nodes_between_nodes_in_tree(node1=None, node2=None, only_order=False):
"""
This procedure searches a tree for all nodes between node1 and node2.
In case node1 is None: it should start in the first node
If node2 is None: it should end in the last node
:param node1:
:param node2:
:param only_order: we only care about which nodes comes before.
Not the nodes in between.
:return: (n1, n2, list): the order of the nodes and a list of nodes in between.