This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This regex matchex everything between 2 quotes (including double quotes and single quotes | |
$arg =~ /(["'])(?:(?=(\\?))\2.)*?\1/g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The structure of the node is | |
typedef struct node | |
{ | |
int freq; | |
char data; | |
node * left; | |
node * right; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Node is defined as | |
typedef struct node | |
{ | |
int data; | |
node * left; | |
node * right; | |
}node; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[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 = "" |