Skip to content

Instantly share code, notes, and snippets.

@rduque1
rduque1 / heroku_env_cop.sh
Created August 1, 2017 06:17
Heroku copy env vars
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@rduque1
rduque1 / gist:d402db4d1bcecf2785db6f4a55bcf2c3
Created September 14, 2017 09:57
How to start a stopped Docker container with a different command?
https://stackoverflow.com/questions/32353055/how-to-start-a-stopped-docker-container-with-a-different-command
@rduque1
rduque1 / google_storage_signed_url.sh
Created September 14, 2017 11:57
Create gs signed url
# -d number of days valid url
gsutil signurl -d 2d ~/.ssh/key_service_account_gc_gsutil-signedurl.txt gs://path
@rduque1
rduque1 / svg-image2.js
Created November 8, 2017 14:04 — forked from iwek/svg-image2.js
D3js click function to save SVG as dataurl in IMG tag, load into CANVAS and save as PNG dataurl, and auto download the actual PNG file.
d3.select("#save").on("click", function(){
var html = d3.select("svg")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node().parentNode.innerHTML;
//console.log(html);
var imgsrc = 'data:image/svg+xml;base64,'+ btoa(html);
var img = '<img src="'+imgsrc+'">';
d3.select("#svgdataurl").html(img);
@rduque1
rduque1 / s3Sync.sh
Created June 24, 2018 01:52 — forked from kellyrmilligan/s3Sync.sh
Sync files to s3 and set cache control headers
#!/bin/bash
if [[ "$1" != "" ]]; then
S3BUCKETNAME="$1"
else
echo ERROR: Failed to supply S3 bucket name
exit 1
fi
aws s3 sync build s3://$S3BUCKETNAME --delete --cache-control max-age=31536000,public
@rduque1
rduque1 / bash.sh
Last active December 2, 2018 16:04
s3 maxage
aws s3 cp \
--metadata-directive REPLACE \
--cache-control max-age=1,s-maxage=1 \
./index.html \
s3://bucket/dist/index.html
aws s3 sync \
--metadata-directive REPLACE \
--cache-control max-age=1,s-maxage=1 \
./index.html
@rduque1
rduque1 / docker-compose-restart-specific-service.sh
Created March 11, 2019 12:36
Docker compose rebuild and replace container
docker-compose up -d --force-recreate --no-deps --build <SERVICE>
# Options description:
#
#Options:
# -d Detached mode: Run containers in the background,
# print new container names. Incompatible with
# --abort-on-container-exit.
# --force-recreate Recreate containers even if their configuration
# and image haven't changed.
# --build Build images before starting containers.
@rduque1
rduque1 / docker-logs-size.sh
Created March 11, 2019 15:23
Get size of docker logs
docker ps -qa | xargs docker inspect --format='{{.LogPath}}' | xargs ls -hl
@rduque1
rduque1 / index.html
Last active July 8, 2019 06:42
Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@rduque1
rduque1 / port.sh
Created July 12, 2019 07:36
Get all ports used
sudo lsof -i -P -n