Skip to content

Instantly share code, notes, and snippets.

@tdshipley
tdshipley / get_using_httpclient.cs
Last active March 10, 2023 16:17
An example of GET request using HttpClient in C#
namespace API.Controllers
{
public class GithubController : ApiController
{
private const string _address = "https://api.github.com/users/tdshipley";
private const string _userAgent = "TestApp";
// GET api/<controller>
public async Task<string> Get()
{
@tdshipley
tdshipley / wait_for_test_to_complete_running_in_k8s_pod.sh
Created June 5, 2019 09:42
Script to wait for a test to finish running in a K8s Pod
passed="false"
failed="false"
while [ "$failed" == "false" ] && [ "$passed" == "false" ] && [ $tryCount -lt $maxWaitTime ]
do
tryCount=$((tryCount + 1))
podLogs=$(kubectl logs --tail=80 pods/$runningPod)
case $podLogs in
*"Test run passed"*) passed="true";;
@tdshipley
tdshipley / find_running_pod_for_job.sh
Created June 5, 2019 09:39
Script to find a running pod for a job in GCP K8s Engine
tryCount=0
runningPod=""
while [ "$runningPod" == "" ] && [ $tryCount -lt 12 ]
do
tryCount=$((tryCount + 1))
echo "Searching for pod... try $tryCount of 12"
sleep 5
runningPod="$(kubectl get pods --selector=job-name=$jobName --output=jsonpath={.items..metadata.name})"
done
apiVersion: batch/v1
kind: Job
metadata:
labels:
job-name: run-perf-test-latest-${VERSION}
name: run-perf-test-latest-${VERSION}
namespace: my-gcp-namespace
spec:
backoffLimit: 1
completions: 1
@tdshipley
tdshipley / mapping-file.json
Created April 29, 2019 15:44
Mapping file for Dependency Checker and OWASP Glue
{
"app_name": "my_app_name",
"task_name": "OWASP Dependency Checker",
"mappings": [
{
"key": "alerts",
"properties": {
"description": "description",
"detail": "detail",
"source": "source",
@tdshipley
tdshipley / owasp_glue_dep_check_dynamic_task.sh
Created April 29, 2019 15:05
OWASP Glue Change Dependency Checker JSON output To Dynamic Compatible Version
jq '{
alerts:
[ .dependencies |
map(select(.vulnerabilities != null)) |
.[] |
. as $raw |
$raw |
$raw.vulnerabilities |
. as $vuln |
{
@tdshipley
tdshipley / sonarqube_scanner_example_output.txt
Created November 6, 2018 14:58
Sonar-Scanner example output
Thomass-MacBook-Pro:kotlin thomas$ sonar-scanner
<Redacted for brevity>
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/4a27fa8c666747f6956d75ae63fb24b9
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AWbpY5h5xoaTc7Huvu3D
INFO: Task total time: 4.403 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 5.628s
@tdshipley
tdshipley / sonarqube_properties_example_file.properties
Created November 6, 2018 14:51
Example SonarQube Properties File
#----- SonarQube server
sonar.host.url=http://localhost:9000
#----- Project Key
sonar.projectKey=4a27fa8c666747f6956d75ae63fb24b9
#----- Project Name
sonar.projectName=MyProjectName
#----- Project Version
@tdshipley
tdshipley / docker_container_ls_example.txt
Created November 6, 2018 14:42
Docker Container List Example
Thomass-MacBook-Pro:kotlin thomas$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68be74d0aa51 sonarqube "./bin/run.sh" About an hour ago Up About an hour 0.0.0.0:9000->9000/tcp, 0.0.0.0:9092->9092/tcp gracious_noyce
@tdshipley
tdshipley / dockerhub_pull_image_output.txt
Created November 6, 2018 14:37
Docker Hub Pull Image Example Output
Unable to find image 'sonarqube:latest' locally
latest: Pulling from library/sonarqube
bc9ab73e5b14: Pull complete
193a6306c92a: Pull complete
e5c3f8c317dc: Pull complete
a587a86c9dcb: Pull complete
a4c7ee7ef122: Pull complete
a7c0dad691e9: Pull complete
367a6a68b113: Pull complete
60c0e52d1ec2: Pull complete