Skip to content

Instantly share code, notes, and snippets.

@ryanc414
ryanc414 / git-rm-merged
Last active July 12, 2022 12:17
Delete merged git branches locally and on remote
#!/bin/bash
# Remove merged git branches locally and on remote(s)
set -e
# Script constants
BRANCH_WHITELIST="(\*|master|other-special-branches)"
REMOTES="origin" # Add more remotes here as space-separated list
echo "Deleting merged branches locally"

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@ryanc414
ryanc414 / app.go
Last active April 28, 2020 10:39
PyTest fixture examples
package main
import (
"flag"
"fmt"
"html"
"net"
"net/http"
)
"""Example usage of pytest fixtures."""
import subprocess
import re
import pytest
import requests
class App:
@pytest.fixture
def app():
app = App()
print("Starting app")
app.start()
yield app
print("Stopping app")
app.stop()
@pytest.fixture(scope="module")
def app():
app = App()
print("Starting app")
app.start()
yield app
print("Stopping app")
app.stop()
# First test with the default port, then test using a fixed port
# number.
@pytest.fixture(scope="module", params=[None, 9999])
def app(request):
app = App(port=request.param)
print("Starting app")
app.start()
yield app
print("Stopping app")
app.stop()
class AppClient:
def __init__(self, app_addr):
self._app_addr = app_addr
def request(self, method, path):
return requests.request(method, f"{self._app_addr}{path}")
@pytest.fixture(scope="function")
def app_client(app):
@ryanc414
ryanc414 / process_json.go
Created September 24, 2020 19:33
Process a JSON file, in Go
package main
import (
"encoding/json"
"errors"
"flag"
"fmt"
"io/ioutil"
"os"
)
@ryanc414
ryanc414 / lists.go
Created September 24, 2020 22:35
linked lists in Go
package main
import (
"fmt"
"container/list"
)
func main() {
l := list.New()
l.PushBack(2)