brew install go
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
import json | |
from django.test import RequestFactory | |
from django.http import QueryDict | |
def generate_http_request(url, user, method='GET', query_params=None, data=None, headers=None, request_attrs=None): | |
""" | |
Generate an HTTP request for a given URL and user. | |
Args: | |
url (str): The URL for the request. |
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
import os | |
def print_logging_params(logging_dict): | |
# Print handlers | |
if 'handlers' in logging_dict: | |
print('* Handlers:') | |
for name, handler in logging_dict['handlers'].items(): | |
print(f" * {name.capitalize()} '{name}'") | |
if 'class' in handler: |
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
import subprocess | |
import json | |
# Get a list of all nodes in the Docker swarm | |
result = subprocess.run(["docker", "node", "ls", "--format", "{{json .}}"], stdout=subprocess.PIPE, text=True) | |
nodes = json.loads("[" + result.stdout.strip().replace("}\n{", "},\n{") + "]") | |
# Iterate over the nodes and print their hostname and IP address | |
for node in nodes: | |
print("Node:", node['Hostname']) |
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
import django.http | |
def convert_curl_to_httprequest(curl_statement): | |
import re | |
# Split by spaces | |
curl_parts = curl_statement.split(' ') | |
# Get method | |
method = curl_parts[1] |
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
#/usr/bin/env python3 | |
""" | |
LogScan - by David Daniel (david.daniel@cyware.com) | |
=================================================== | |
Usage | |
----- | |
usage: logscan.py [-h] [--end_time end_time] [--start_time start_time] | |
directory [directory ...] date pattern |
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
func startCapturingStdout() { | |
// capture things from stdout | |
suite.Old = os.Stdout // keep backup of the real stdout | |
r, w, _ := os.Pipe() | |
suite.R = r | |
suite.W = w | |
os.Stdout = suite.W |
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
// IMPORTANT: I'll need to fix this when we go past iOS 13. | |
// Assume the following logic is inside a State<StatefulWidget> | |
supportsAppleSignIn = false; | |
@override | |
void initState() { | |
super.initState(); | |
// initialize the AuthAgent | |
this.authAgent = AuthAgent(); |
I swap between databases all the time for various projects, and end up Googling on how to do the inital setup all the time, so the purpose of this document is to list a set of commands that anyone would end up using in getting started.
Login to the MySQL console as the root user, with your password for the root user.
NewerOlder