Skip to content

Instantly share code, notes, and snippets.

@DiegoTc
DiegoTc / rds_to_docker.md
Created March 15, 2020 22:51 — forked from herval/rds_to_docker.md
Moving a Postgres db from RDS to a Docker container

Make a backup from RDS

pg_dump -h <rds host> -p 5432 -F c -O -U <rds user> <db name> > db.dump

Restore the backup into a Docker container

docker run --rm --interactive --link <postgres container id>:postgres --volume $PWD/:/tmp/ postgres:latest /bin/bash -c 'pg_restore --verbose --clean --no-acl --no-owner -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -d <db name> /tmp/db.dump'
@DiegoTc
DiegoTc / delete_all_awslogs.sh.md
Created February 17, 2020 19:10 — forked from pahud/delete_all_awslogs.sh.md
delete all aws log groups

specify the region

export AWS_DEFAULT_REGION=ap-northeast-1
aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output table | \
awk '{print $2}' | grep -v ^$ | while read x; do  echo "deleting $x" ; aws logs delete-log-group --log-group-name $x; done

only delete loggroup name starting with /aws/lambda

@DiegoTc
DiegoTc / terraform-aws-wait-healthy.sh
Created November 7, 2019 03:12 — forked from ryane/terraform-aws-wait-healthy.sh
Waits for AWS instances launched from Terraform to become healthy
aws ec2 wait instance-status-ok --instance-ids $(cat terraform.tfstate | jq '.modules[].resources[] | select(.type == "aws_instance") | .primary.attributes.id' | sed 's/\"//g' | tr '\n', ' '; echo '')
@DiegoTc
DiegoTc / read-access.sql
Last active December 13, 2018 22:21 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@DiegoTc
DiegoTc / CARD_0.html
Created August 12, 2014 21:26 — forked from VoltVisionFrenchy/CARD_0.html
Bone101 Tutorial
You will need a photosensor like this...<div><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4UZ8RXhpZgAASUkqAAgAAAALAA8BAgAGAAAAkgAAABABAgAUAAAAmAAAABIBAwABAAAAAQAAABoBBQABAAAAuAAAABsBBQABAAAAwAAAACgBAwABAAAAAgAAADIBAgAUAAAAyAAAADsBAgABAAAAAAAAABMCAwABAAAAAgAAAJiCAgABAAAAAAAAAGmHBAABAAAAXAEAAHYiAABDYW5vbgBDYW5vbiBFT1MgUkVCRUwgVDNpAAAAAAAAAAAAAAAAAEgAAAABAAAASAAAAAEAAAAyMDE0OjA1OjAxIDEzOjA5OjUxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJgCaggUAAQAAACoDAACdggUAAQAAADIDAAAiiAMAAQAAAAIAAAAniAMAAQAAAKAAAAAwiAMAAQAAAAIAAAAyiAQAAQAAAKAAAAAAkAcABAAAADAyMzADkAIAFAAAADoDAAAEkAIAFAAAAE4DAAABkQcABAAAAAECAwABkgoAAQAAAGIDAAACkgUAAQAAAGoDAAAEkgoAAQAAAHIDAAAHkgMAAQAAAAUAAAAJkgMAAQAAAAAAAAAKkgUAAQAAAHoDAAB8kgcADB0AAIIDAACGkgcACAEAAI4gAACQkgIAAwAAADA2AACRkgIAAwAAADA2AACSkgIAAwAAADA2AAAAoAcABAAAADAxMDABoAMAAQAAAAEAAAACoAQAAQAAALsEAAADoAQAAQAAAGsCAAAFoAQAAQAAAJYhAAAOogUAAQAAALQhAAAPogUAAQ
@DiegoTc
DiegoTc / CARD_0.html
Created August 11, 2014 12:34 — forked from Dicetog/CARD_0.html
Bone101 Tutorial
<h1 style="font-size: 2em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">writeTextFile(filename, data, [callback])</h1><p style="font-size: 1.1em; line-height: 1.3em; color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">Write the contents of a text (ASCII) file.</p><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; font-weight: normal; color: rgb(180, 162, 121); mar
@DiegoTc
DiegoTc / CARD_0.html
Created August 11, 2014 03:11 — forked from Dicetog/CARD_0.html
Bone101 Tutorial
<h1 style="font-size: 2em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">writeTextFile(filename, data, [callback])</h1><p style="font-size: 1.1em; line-height: 1.3em; color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">Write the contents of a text (ASCII) file.</p><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; font-weight: normal; color: rgb(180, 162, 121); mar

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

function summernoteLoad() {
var $summernoteTextAreas = $('[data-control="summernote"]');
//cargar summernote
$summernoteTextAreas.summernote({
onImageUpload: summernoteOnImageUpload,
onkeyup: function() {
syncSummernoteTextArea($summernoteTextAreas);
validate(false);
},

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results