Skip to content

Instantly share code, notes, and snippets.

View oir's full-sized avatar

Ozan İrsoy oir

View GitHub Profile
@oir
oir / iterm2_switch_automatic.md
Created January 27, 2024 14:25 — forked from FradSer/iterm2_switch_automatic.md
Switch iTerm2 color preset automatic base on macOS dark mode.

The latest beta (3.5) includes separate color settings for light & dark mode. Toggling dark mode automatically switches colors.

Vist iTerm2 homepage or use brew install iterm2-beta to download the beta. Thanks @stefanwascoding.


  1. Add switch_automatic.py to ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch with:
@oir
oir / tree.py
Last active February 9, 2016 20:14
# Given a binary tree, this routine computes new coordinates for visualization purposes
# (reduces overlap between nodes).
# ix (paix) should be np.arrays that have integer indices for nodes (parent nodes).
# paix of root should be -1.
# depth is a np.array with integer value of the depth, and
# coords is 2d initial coordinates of each node.
# It works as follows, as a physics simulation:
# - y coordinates are fixed by looking at the depth (not free).
@oir
oir / HashedArray.cpp
Created May 17, 2013 21:39
Hashed Array, a set type data structure which has O(1) insertion, O(1) removal, and O(1) uniformly randomly retrieval.
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;
// Hashed array
template <class T>
class HashedArray
@oir
oir / hgfc.R
Last active December 15, 2015 06:29
Hierarchical Graph Factorization (Soft) Clustering. See: Yu, Kai, Shipeng Yu, and Volker Tresp. "Soft clustering on graphs." Advances in Neural Information Processing Systems 18 (2006): 1553.
# Ozan Irsoy, 2013
# Graph factorization.
# W: adjacency matrix
# m: # clusters (# vertices in U)
gfact = function(W, m) {
n = dim(W)[1]
H = matrix(runif(n*m,1,2),n,m)
L = diag(runif(m,1,2))