Skip to content

Instantly share code, notes, and snippets.

@ssd532
ssd532 / docker_ip_resolver.sh
Last active April 7, 2023 10:02
Update the /etc/hosts file with Docker container IPs and names
#!/bin/bash
DOCKER_HOSTS_FILE="$HOME/tmp/docker-hosts"
HOSTS_NEW_FILE="$HOME/tmp/hosts.new"
# Get the list of running containers
CONTAINER_IDS=$(docker ps -q)
# Clear the current Docker hosts file
echo "# Docker container IPs" > $DOCKER_HOSTS_FILE
@ssd532
ssd532 / index.html
Last active March 7, 2020 05:37
async/await JS Bin// source https://jsbin.com/milexor
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="async-await-blocking">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@ssd532
ssd532 / lambda-route53-dyn-dns.js
Created December 18, 2019 19:02
aws lambda dynamic dns records updation upon ec2 instance state change
const AWS = require('aws-sdk')
let params = {
InstanceIds: [
"i-something"
]
};
let route53params = {
"HostedZoneId": "", // zone id
@ssd532
ssd532 / ec2-instance-reboot.sh
Last active December 18, 2019 18:55
aws-cli: ec2 instance reboot bash script
#!/bin/bash
instanceId="i-something"
aws ec2 stop-instances --instance-ids $instanceId;
aws ec2 wait instance-stopped --instance-ids $instanceId;
aws ec2 start-instances --instance-ids $instanceId;
aws ec2 wait instance-running --instance-ids $instanceId;
echo "machine running"
@ssd532
ssd532 / cron_helper.sh
Created October 17, 2015 14:40 — forked from liquidgecka/cron_helper.sh
Cron helper
#!/bin/bash
usage() {
cat << EOF
Usage: $0 [OPTION]... COMMAND
Execute the given command in a way that works safely with cron. This should
typically be used inside of a cron job definition like so:
* * * * * $(which "$0") [OPTION]... COMMAND
Arguments:
@ssd532
ssd532 / gist:70d6ec5cf2d66c839bf2
Last active August 29, 2015 14:19
Haskell: names of notations and operators
Notations
.. - enumeration
:: - It's not really a notation but still... x :: y means "the expression x has the type y"
- Alternatively, from Real World Haskell "The combination of :: and the type after it is called a type signature."
lines :: String -> [String]
We can read the -> above as “to”, which loosely translates to “returns”. The signature as a whole thus reads as “lines has the type String to list-of-String”. Let's try applying the function.
@ssd532
ssd532 / firefoxWithDebug.sh
Last active August 29, 2015 14:13 — forked from ibc/Chrome.sh
#!/usr/bin/env bash
#
# Run Firefox with WebRTC debugging.
# - Signaling (SDP) logs go to SIGNALING_FILE.
# - ICE/STUN/TURN logs go to stderr.
#
FIREFOX_EXEC=/Applications/Firefox.app/Contents/MacOS/firefox
SIGNALING_FILE=/tmp/firefox_signaling.log