Skip to content

Instantly share code, notes, and snippets.

@mdelillo
mdelillo / prevent_default_spec.js
Last active June 22, 2016 21:54
Testing preventDefault in react
var preventDefaultHandler = jasmine.createSpy('defaultPreventedHandler');
React.addons.TestUtils.Simulate.click(
link,
{ preventDefault: function() { preventDefaultHandler.call(); }}
);
expect(preventDefaultHandler).toHaveBeenCalled();
@mdelillo
mdelillo / index.html
Last active April 20, 2016 14:00
PCF Dev CI
<html>
<head>
<style>
body {
border: none;
margin: 0px;
padding: 0px;
overflow: hidden;
}
iframe {
# winrm quickconfig -q
cmd.exe /c 'winrm quickconfig -q'
"winrm quickconfig -q (Exit Code: ${LASTEXITCODE})"
# winrm quickconfig -transport:http
cmd.exe /c 'winrm quickconfig -transport:http'
"winrm quickconfig -transport:http (Exit Code: ${LASTEXITCODE})"
# Win RM AllowUnencrypted
cmd.exe /c 'winrm set winrm/config/service @{AllowUnencrypted="true"}'
@mdelillo
mdelillo / element-not-found-repro.go
Created December 19, 2017 15:55
Reproduction of "Element not found" error when hot attaching HCS endpoint to container
package main
import (
"crypto/rand"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"math"
"math/big"
@mdelillo
mdelillo / login-fly.sh
Created June 4, 2018 21:13
Use your browser to automatically log in to fly
login-fly ()
{
expect <(cat <<EOF
spawn fly -t credhub login
expect "1: GitHub"
send -- "1\r"
expect -re "https://.*fly_local_port=\[0-9\]*"
set url [ string map { "\&" "\\\&" } \$expect_out(0,string) ]
system open \$url
#!/bin/bash
set -e
credhub_pid=$(cat /var/vcap/sys/run/credhub/pid)
uaa_pid=$(cat /var/vcap/data/sys/run/uaa/uaa.pid)
lsof_output="$(lsof)"
total_open_files=$(echo "$lsof_output" | wc -l)
@mdelillo
mdelillo / certs.go
Created July 22, 2018 21:44
Create a self-signed CA and use it to create a signed certificate
package main
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
@mdelillo
mdelillo / insert-lines.sh
Last active March 14, 2020 01:33
Insert multiple lines containing trailing slashes after a matching line in a file
#!/usr/bin/env bash
set -euo pipefail
cat >file.txt << 'EOF'
LINE 1 \
LINE 2 \
LINE 5
EOF
@mdelillo
mdelillo / parallel-jobs-in-batches.sh
Last active April 30, 2019 18:56
Run batches of bash things in parallel
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -ne 1 ]; then
echo "Usage: $(basename "$0") <number-of-times-to-run-job>"
exit 1
fi
total_runs="$1"
#!/usr/bin/env bash
for pipeline in $(fly -t "$target" pipelines --json | jq -r '.[].name'); do
for job in $(fly -t "$target" jobs -p "$pipeline" --json | jq -r '.[].name'); do
for build in $(fly -t "$target" builds -j "$pipeline/$job" -c 10 --json | jq -r '.[] | select(.status != "pending" and .status != "started").name'); do
( fly -t "$target" watch -j "$pipeline/$job" -b "$build" | grep -q "$SEARCH_PATTERN" && echo "$pipeline/$job/$build" ) &
done
done
done