Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#--------------------------------------------------------------------------------#
# #
# Fix WSL DNS resolution with Cisco AnyConnect #
# #
# ! Don't forget to set this configuration in /etc/wsl.conf: #
# [network] #
# generateResolvConf = false #
# #
# Based on: #
@drankard
drankard / update_aws_profile.sh
Created August 6, 2019 14:25
A small helper script to make the anoying copy paste a bit less anoying....
#!/bin/bash
CREDENTIALS_FILE=~/.aws/credentials
remove_profile() {
PROFILE=${1}
echo "Paste profile data from SSO"
sed -i -e "/\[${PROFILE}\]/,+3d" ${CREDENTIALS_FILE}
}
@drankard
drankard / sign-url.clj
Created July 4, 2017 10:07
Sign url til s3
(defn sign-url [{:keys [s3-bucket s3-key http-method-str content-type] :as all}]
(let [s3-key (if (string? s3-key)
s3-key
(str "tmp-" (java.util.UUID/randomUUID) ".json"))
http-method-str (or http-method-str "GET")
content-type (or content-type "application/octet-stream")
expires (-> 3 t/hours t/from-now to-date)
s3-client (AmazonS3Client. (DefaultAWSCredentialsProviderChain.))
s3-url (.getResourceUrl s3-client s3-bucket s3-key)
url (.generatePresignedUrl s3-client
#!/bin/bash
HELP=false
LIST=false
DELETE=false
TAG=EMPTY
REPOSITORY=EMPTY
ACCEPT_HEADER="application/vnd.docker.distribution.manifest.v2+json"
total 1608
#!/bin/bash
host=$1
ping $host | while read pong; do
echo $pong | grep --line-buffered -o 'time=\S*' | \
sed -e 's/time=//' | \
xargs -I {} aws cloudwatch put-metric-data --namespace wifi-ping --metric-name ping-latency --dimensions "host=$host" --timestamp "$(date)" --unit Milliseconds --value {}
done
@drankard
drankard / cloudwatch.clj
Last active September 12, 2016 13:51
Onyx CloudWatch metric sender (stub)
......
......
(:import (com.amazonaws ClientConfiguration)
(com.amazonaws.auth BasicAWSCredentials)
(com.amazonaws.services.cloudwatch AmazonCloudWatchClient)
(com.amazonaws.services.cloudwatch.model PutMetricDataRequest MetricDatum StandardUnit Dimension))
(defn get-aws-client [aws-config]
(info (str "aws-config: " aws-config))
(let [port (:https-proxy-port aws-config)
(defn update-in-dataset
"Takes a dataset and apply the func on the value of the given keys"
[dataset keys func]
(let [t (fn [k m] (reduce #(assoc %1 %2 (func (%2 %1))) m k))]
(map #(t keys %) dataset)))
@drankard
drankard / gist:7cd3a17e5a56a86ae3be
Last active August 29, 2015 14:18
.bash_profile - ssh-agent
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
@drankard
drankard / lxc.sh
Last active August 29, 2015 14:13
A little helper managing lxc containers
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
AMOUNT=5
NAME="xymon"
@drankard
drankard / user.keymap
Created January 23, 2014 13:17
LightTable keymap
{:+ {:app {}
:editor {"alt-w" [:editor.watch.watch-selection]
"alt-shift-w" [:workspace.show]
"alt-shift-c" [:toggle-console]
"ctrl-left" [:paredit.shrink.right]
"ctrl-right" [:paredit.grow.right]
}}}