Skip to content

Instantly share code, notes, and snippets.

View domanchi's full-sized avatar

Aaron Loo domanchi

View GitHub Profile
@domanchi
domanchi / description.md
Created December 10, 2021 06:05
WSL VPN DNS Fix

WSL VPN DNS Fix

Problem

On Windows Subsystem for Linux (WSL), I noticed a perculiar thing when I connected to VPN -- the network connections stopped working. This problem was consistent across devices, and based on my SRE experience, I knew that it was probably a DNS problem. I just didn't know how to resolve it.

Then, I came across this thread, which kicked off the appropriate rabbit hole to search in to resolve my long standing problem.

Solution

@domanchi
domanchi / register_factory.py
Created November 5, 2019 23:39
Code samples for Yelp's Engineering Blog announcing the release of fuzz-lightyear.
@fuzz_lightyear.register_factory('userID')
def create_biz_user_id():
return do_some_magic_to_create_business()
#!/bin/python3.6
import email
import logging
import os
import select
from io import StringIO
from socketserver import StreamRequestHandler
from socketserver import TCPServer
from socketserver import ThreadingMixIn
@domanchi
domanchi / api_cmds-base.py
Last active November 16, 2017 19:12
[flask sockets] boilerplate for writing Flask services with socket.io functionality #python #fullstack #javascript #flask
from cmds.base import FlaskView as CmdFlaskView
class FlaskView(CmdFlaskView):
route_prefix = '/api'
@classmethod
def on_socket_event(cls, event_name):
"""Registers a listener for websocket events.
@domanchi
domanchi / snippet.md
Created November 3, 2017 20:08
[bash return values] The better way to break bash scripts into functions. #bash

Bash Functions Return Values

The lame, old way: passing in a global variable, setting it in the function, then unsetting it later on.

#!/bin/bash

function foobar() {
    eval $1="some return value"
}
@domanchi
domanchi / snippet.md
Last active September 20, 2017 16:19
[python packages] cheatsheet for pip #python

Installing from local repository

pip install -e <path_to_root_file_with_setup.py>

Installing for a different version of Python

Use pip2.7 (or the like) instead.

@domanchi
domanchi / snippet.md
Created September 14, 2017 15:40
[git cheatsheet] handy commands for git #git

Deleting git tags

# Delete tag on remote, before you push
git push origin :refs/tags/<tagname>

# Replace the tag to reference the most recent commit
git tag -fa <tagname>

# Push the tag to remote
@domanchi
domanchi / snippet.md
Last active September 14, 2017 15:15
[handy linux commands] Cheatsheet for cool things you can do with bash. #bash

Rename selected files using a regular expression

rename 's/\.bak$/.txt/' *.bak

Process Management

Check how long something takes to run

@domanchi
domanchi / cheatsheet.md
Last active April 5, 2024 06:30
[splunk cheatsheet] Splunk snippets, because their syntax is so confusing. #splunk

Splunk Queries

I really don't like Splunk documentation. Why is it so hard to find out how to do a certain action? So this is a cheatsheet that I constructed to help me quickly gain knowledge that I need.

Analysis

Events over time

index="my_log"
@domanchi
domanchi / switch.sh
Last active August 25, 2018 14:09
[switch statement] This is how to do switch statements in bash script #bash
#!/bin/bash
function main() {
case $1 in
a)
echo "You typed in 'a'!"
;;
b | 'd')
# This fallthrough operator is introduced in Bash v4.