Skip to content

Instantly share code, notes, and snippets.

View guumaster's full-sized avatar
:octocat:
⌨️

Gustavo Marin guumaster

:octocat:
⌨️
View GitHub Profile
@guumaster
guumaster / stdin_detect.sh
Created March 8, 2013 23:56
Deteccion de tipo de entrada/salida en ficheros bash
#!/bin/bash
if [[ -p /dev/stdin ]]
then
echo "stdin is coming from a pipe"
fi
if [[ -t 0 ]]
then
echo "stdin is coming from the terminal"
fi
if [[ ! -t 0 && ! -p /dev/stdin ]]
@guumaster
guumaster / read_password.sh
Created March 8, 2013 23:58
Read password from stdin
#!/bin/bash
unset password
prompt="Secret Password:"
while IFS= read -p "$prompt" -r -s -n 1 char
do
if [[ $char == $'\0' ]]
then
break
fi
#prompt='*' # to show * for every keystroke
@guumaster
guumaster / Reduce Disk Size.txt
Last active December 18, 2015 00:09
Reduce VirtualBox VDI image size.
1. Install zerofree program:
sudo apt-get install zerofree
2. Reboot Ubuntu.
3. Press <Shift> to enter grub menu.
4. From grub menu select "recovery mode".
@guumaster
guumaster / backup.sh
Created June 16, 2013 12:42
How to: Backup & Restore packages using dselect-upgrade
sudo dpkg --get-selections > /tmp/dpkglist.txt
@guumaster
guumaster / sprintf.js
Created October 17, 2013 15:02
quick&dirty sprintf
function format(str) {
var args = [].slice.call(arguments);
str = args.shift();
return str.replace(/%(\d+)/g,
function(match, i) {
return args[--i];
});
}
@guumaster
guumaster / .gitconfig
Created September 19, 2014 09:28
My global gitconfig
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
@guumaster
guumaster / ports.py
Last active August 29, 2015 14:08
How to check your Raspberry Pi revision
import RPi.GPIO as GPIO
if GPIO.RPI_REVISION == 1:
ports = [0, 1, 21]
else:
ports = [2, 3, 27]
print "Your Pi is a Revision %s, so your ports are: %s" % (GPIO.RPI_REVISION, ports)
@guumaster
guumaster / 00-README.md
Last active January 23, 2023 15:48
How to upload a file with $.ajax to AWS S3 with a pre-signed url

Upload a file with $.ajax to AWS S3 with a pre-signed url

When you read about how to create and consume a pre-signed url on this guide, everything is really easy. You get your Postman and it works like a charm in the first run.

Then you open your browser, try your usual $.ajax() and send your PUT operation, and you hit the cold iced wall of AWS error message, a simple <Code>SignatureDoesNotMatch</Code> that will steal hours from your productivity.

So here I come to save you and give you a free working example of how to upload a file directly to AWS S3 from your browser. You are wellcome :).

'use strict';
let convert = (str) => {
return str
.trim()
.split(/ +/)
.reduce((acc, word) => {
return (acc + ' ' + word[0].toUpperCase() + word.slice(1).toLowerCase()).trim();
}, '');
}
'use strict';
let convert = require('./convert');
let freq = require('./frequency');
let input = process.argv[2] || 'EMPTY';
console.log( freq(convert(input)));