This file contains 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
#!/bin/bash | |
set -o errexit -o nounset -o pipefail | |
# Generate kaf (https://github.com/birdayz/kaf) configuration with AWS MSK clusters | |
# Usage: | |
# # Setup new config: | |
# AWS_PROFILE=dev ./gen-kaf-conf.sh > ~/.kaf/config && kaf config select-cluster | |
# | |
# # Append to existing config (tail command removes first line): | |
# AWS_PROFILE=dev ./gen-kaf-conf.sh | tail -n+2 >> ~/.kaf/config |
This file contains 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
#!/bin/bash | |
# Note: Must run as root! | |
cd /etc/wireguard/ | |
# Get next available internal IP address | |
IP=$((`tac wg0.conf | grep -m1 -oP "[0-9]+(?=/32)" || echo 1` + 1)) | |
# Generate client key | |
CLIENT_PRIVATE=`wg genkey` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
# python3 | |
from collections import deque | |
# Store combinations as a tree. The size of the tree directly | |
# corresponds to the running time of the algorithm - O(2^n) | |
# Worst runtime is when the sum of items is larger than the target | |
# and no combination exist. An intuitive optimization here is to | |
# prune combinations away when the sum has already exceeded the target | |
class Node: |
This file contains 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
public class Solution { | |
private IList<IList<int>> graph; | |
private bool[] marked; | |
private bool[] onStack; | |
private bool hasCycle; | |
private Stack<int> s; | |
public int[] FindOrder(int numCourses, int[,] prerequisites) { | |
graph = new List<IList<int>>(); | |
marked = new bool[numCourses]; |
This file contains 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
public class Solution { | |
private IList<IList<int>> graph; | |
private bool[] marked; | |
private bool[] onStack; | |
private bool hasCycle; | |
public bool CanFinish(int numCourses, int[,] prerequisites) { | |
graph = new List<IList<int>>(); | |
marked = new bool[numCourses]; | |
onStack = new bool[numCourses]; |
This file contains 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
public class Solution { | |
IList<IList<int>> graph; | |
bool[] marked; | |
public bool CanVisitAllRooms(IList<IList<int>> rooms) { | |
graph = rooms; | |
marked = new bool[rooms.Count]; | |
dfs(0); | |
This file contains 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
/****************************************************************************** | |
* Execution: ./DisjointSet < input.txt | |
* Data files: http://algs4.cs.princeton.edu/15uf/tinyUF.txt | |
* http://algs4.cs.princeton.edu/15uf/mediumUF.txt | |
* http://algs4.cs.princeton.edu/15uf/largeUF.txt | |
* | |
* Weighted quick-union by rank with path compression. | |
* | |
* % ./DisjointSet < tinyUF.txt | |
* 4 3 |
This file contains 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
# Python3 port of http://algs4.cs.princeton.edu/code/edu/princeton/cs/algs4/UF.java.html | |
class DisjointSet: | |
""" | |
Execution: python disjoint_set.py < input.txt | |
Data files: http://algs4.cs.princeton.edu/15uf/tinyUF.txt | |
http://algs4.cs.princeton.edu/15uf/mediumUF.txt | |
http://algs4.cs.princeton.edu/15uf/largeUF.txt | |
Weighted quick-union by rank with path compression. | |
This file contains 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 <iostream> | |
using namespace std; | |
struct Byte { | |
void to4Bits(char c) | |
{ | |
lo = c >> 4; | |
hi = c & 0x0F; | |
} |
NewerOlder