Skip to content

Instantly share code, notes, and snippets.

Han Kang logicalhan

Block or report user

Report or block logicalhan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@logicalhan
logicalhan / deprecated-metric-instantation.go
Last active Apr 1, 2019
Metric instantiation with deprecated version
View deprecated-metric-instantation.go
var RegisteredWatchers = kubemetrics.NewGaugeVec(
kubemetrics.GaugeOpts{
Name: "apiserver_registered_watchers",
Help: "Number of currently registered watchers for a given resources",
DeprecatedVersion: "1.15"
},
[]string{"group", "version", "kind"},
)
View issue-72244.yaml
---
apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1beta1.external.metrics.k8s.io
spec:
insecureSkipTLSVerify: true
group: external.metrics.k8s.io
groupPriorityMinimum: 100
versionPriority: 100
@logicalhan
logicalhan / fenwick_tree.py
Created Oct 18, 2016
binary indexed tree
View fenwick_tree.py
class FenwickTree(object):
def __init__(self, arr):
self._one_based_indexed_arr = [0] + arr
self._bit = [0] * (len(arr)+2)
self._len = len(self._one_based_indexed_arr)
for i in range(1, len(self._one_based_indexed_arr)):
index = i
val = self._one_based_indexed_arr[i]
while index < self._len:
self._bit[index] += val
@logicalhan
logicalhan / tarjan.py
Last active Sep 14, 2016
tarjan's strongly connected componen
View tarjan.py
class Tarjan(object):
def __init__(self, edges):
tmp_vs = []
self.edges = edges
vertice_dict = {}
for edge in edges:
if edge[0] not in vertice_dict.keys():
vertice_dict[edge[0]] = {"id": edge[0]}
if edge[1] not in vertice_dict.keys():
vertice_dict[edge[1]] = {"id": edge[1]}
@logicalhan
logicalhan / saas_class_meta.rb
Created Aug 26, 2012
attr_accessor_with_history
View saas_class_meta.rb
class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s
history_method_name = attr_name + "_history"
attr_reader attr_name
attr_reader history_method_name
class_eval(%Q(
def #{attr_name}=(#{attr_name})
@#{attr_name} = #{attr_name}
if @#{history_method_name}
You can’t perform that action at this time.