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
// See https://aka.ms/new-console-template for more information | |
Console.WriteLine("Hello, World!"); | |
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; | |
void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e) | |
{ | |
Console.WriteLine($"!!! Unobserved exception !!! {e.Exception?.GetType().FullName} {e.Exception?.ToString()} {e.Observed}"); | |
} |
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
[Interface] | |
PrivateKey = | |
Address = 172.16.0.2/32 | |
DNS = 1.1.1.1, 1.0.0.1 | |
MTU = 1280 | |
# PostUp = iptables -t nat -A POSTROUTING -o wg+ -j MASQUERADE | |
# PreDown = iptables -t nat -D POSTROUTING -o wg+ -j MASQUERADE | |
PostUp = DROUTE=$(ip route | grep default | awk '{print $3}'); HOMENET=192.168.0.0/16; HOMENET2=10.0.0.0/8; HOMENET3=172.16.0.0/12; ip route add $HOMENET3 via $DROUTE; ip route add $HOMENET2 via $DROUTE; ip route add $HOMENET via $DROUTE; iptables -I OUTPUT -d $HOMENET -j ACCEPT; iptables -A OUTPUT -d $HOMENET2 -j ACCEPT; iptables -A OUTPUT -d $HOMENET3 -j ACCEPT; iptables -A OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT | |
PreDown = HOMENET=192.168.0.0/16; HOMENET2=10.0.0.0/8; HOMENET3=172.16.0.0/12; ip route delete $HOMENET; ip route delete $HOMENET2; ip route delete $HOMENET3; iptables -D OUTPUT ! -o %i -m mark ! --mark $(wg show %i fwmark) -m addrtype ! --dst-type LOCAL -j REJECT; iptables -D OUTPUT -d $HOMENET -j ACCEPT; iptables -D OUTPUT -d $HOMENET2 |
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
services: | |
wireguard: | |
image: lscr.io/linuxserver/wireguard | |
container_name: wireguard | |
cap_add: | |
- NET_ADMIN | |
- SYS_MODULE | |
environment: | |
- PUID=1000 | |
- PGID=10 |
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
#!/bin/bash | |
# Check if the correct number of arguments is provided | |
if [ "$#" -ne 2 ]; then | |
echo "Usage: $0 <input_file> <output_file>" | |
exit 1 | |
fi | |
# Assign input arguments to variables | |
INPUT_FILE=$1 |
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
services: | |
jellyfin: | |
image: lscr.io/linuxserver/jellyfin:latest | |
container_name: jellyfin | |
environment: | |
- PUID=0 | |
- PGID=0 | |
- TZ=America/Los_Angeles | |
volumes: | |
- /volume1/docker/jellyfin/library:/config |
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
import socket | |
import select | |
PROXY_APP_VLAN_IP = '0.0.0.0' # proxy's IP in the 'source'/app vlan | |
PROXY_IOT_VLAN_IP = '192.168.40.121' # proxy's IP in the iot vlan | |
BROADCAST_PORT = 20002 | |
BUFFER_SIZE = 1024 * 2 | |
RESPONSE_TIMEOUT = 1 # devices are expected to reply to the handshare in 1 sec; otherwise handshake propagation will be delayed |
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
public class NumArray { | |
private readonly int[] tree; | |
private readonly int itemCount; | |
public NumArray(int[] nums) { | |
if (nums.Length == 0) return; | |
itemCount = nums.Length; |
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
public class Solution { | |
public int FindKthLargest(int[] nums, int k) { | |
return KthLargest2(nums, nums.Length - k, 0, nums.Length - 1); | |
} | |
private readonly static Random _rnd = new(); | |
private static int KthLargest(int[] nums, int k, int left, int 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
# generates all valid pair of parens | |
def generate_all_parens(target_len): | |
def generate_parens(string, disbalance_count, next_index, target_len): | |
if next_index == target_len: | |
print(''.join(string)) | |
return |
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
#fully recursive version, including set generation | |
# automates expression search from here: https://www.cut-the-knot.org/do_you_know/digits.shtml | |
# e.g. | |
# 123 - 45 - 67 + 89 = 100 | |
# 123 + 45 - 67 + 8 - 9 = 100 | |
# 123 + 4 - 5 + 67 - 89 = 100 | |
# 123 - 4 - 5 - 6 - 7 + 8 - 9 = 100 | |
# 12 + 3 - 4 + 5 + 67 + 8 + 9 = 100 | |
# ... |
NewerOlder