Skip to content

Instantly share code, notes, and snippets.

View csessh's full-sized avatar
👀

Thang Do csessh

👀
View GitHub Profile
@csessh
csessh / pet.toml
Last active September 13, 2025 13:41
description
[[Snippets]]
Description = "Snipe/Terminate an existing process"
Output = ""
Tag = ["fzf"]
command = "ps aux | fzf --height=40% --layout=reverse --prompt=\"Which process are we killing? > \" | awk '{print $2}' | xargs -r sudo kill"
[[Snippets]]
Description = "Remove, remotely, all feature branches"
Output = ""
@csessh
csessh / dijkstra.py
Last active January 3, 2025 04:41 — forked from kachayev/dijkstra.py
Dijkstra shortest path algorithm based on python heapq heap implementation
from collections import defaultdict
from heapq import heappush, heappop
def dijkstra(edges, start, end) -> Tuple[int, List[str]]:
graph = defaultdict(list)
for src, dest, weight in edges:
graph[src].append((weight, dest))
pq = [(0, start, [])]
seen = set()
@csessh
csessh / lca.cpp
Last active November 6, 2015 16:14
Find the lowest common ancestor in a tree
/*
Node is defined as
typedef struct node
{
int data;
node * left;
node * right;
}node;
@csessh
csessh / huffman.cpp
Created November 6, 2015 16:05
Decode huffman tree
/*
The structure of the node is
typedef struct node
{
int freq;
char data;
node * left;
node * right;
@csessh
csessh / kmp.java
Created November 5, 2015 03:01
kmp algorithm to detect all matches pattern in a string
List<Integer> KMP_all_matches(String haystack, String needle)throws Exception{
//preliminaries
if (null == haystack || haystack.isEmpty()) {
throw new Exception("invalid haystack");
}
if (null == needle || needle.isEmpty()) {
throw new Exception("invalid needle");
}
@csessh
csessh / interview.cpp
Created November 3, 2015 13:56
Some technical interview questions I was asked when interviewed with Misfit Wearables
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
using namespace std;
void Combinations(int max);
void Visit(int* pBuffer, int n, int k);
void Print(const int* pBuffer, const int size);
@csessh
csessh / kmp.py
Last active November 12, 2015 06:10
Quick and simple implementation of KMP pattern matching algorithm
#!/usr/bin/python2.7
import sys
class KMP:
def __init__(self, text):
self.text = text
def suffix_array(self, pattern):
return self._create_suffix_array(pattern)
@csessh
csessh / regex.pl
Created September 27, 2015 23:25
A very useful regex that matches everything between 2 quotes (double or single quotes)
# This regex matchex everything between 2 quotes (including double quotes and single quotes
$arg =~ /(["'])(?:(?=(\\?))\2.)*?\1/g