The curl
manpage isn't super clear on this, but to read from stdin
you need to prepend the dash with a @
.
json_producer | curl -d @- -H 'Content-Type: application/json' http://example.com/json_consumer
The curl
manpage isn't super clear on this, but to read from stdin
you need to prepend the dash with a @
.
json_producer | curl -d @- -H 'Content-Type: application/json' http://example.com/json_consumer
Uploading to Minio (or S3) in a script is a bit tricky.
Update: now on GitHub with some Python versions.
#!/bin/bash
# usage: ./minio-upload my-bucket my-file.zip
bucket=$1
file=$2
host=minio.example.com
s3_key='secret key'
s3_secret='secret token'
resource="/${bucket}/${file}"
content_type="application/octet-stream"
date=`date -R`
_signature="PUT\n\n${content_type}\n${date}\n${resource}"
signature=`echo -en ${_signature} | openssl sha1 -hmac ${s3_secret} -binary | base64`
curl -v -X PUT -T "${file}" \
-H "Host: $host" \
-H "Date: ${date}" \
-H "Content-Type: ${content_type}" \
-H "Authorization: AWS ${s3_key}:${signature}" \
https://$host${resource}
At work we have a large project that is comprised of several nested git repos so having your bash prompt get updated with some vital information such as repo, branch, etc makes life much easier.
Here's an example of my prompt and how it shows the current git repo:
[kurt@machine-1 ~/src/foo/bar/baz venv:foo git:bug_branch repo:bar]
$
I often want to make a directory and then immediately cd
into that directory.
mkdir foo
cd foo
put the following in your .bashrc
function mcd()
{
mkdir $*
args=($*)
cd ${args[@]:(-1)}
}
and then
source ~/.bashrc
mcd -p a/b/c/d
This was originally the majority of this post: Start a django project the right way but I've decided to put in it's own post instead.
I'm assuming you're on OSX. If you're on Linux most of these steps will be the same. If you're on Windows… Install VMWare and then install Linux.
I've added a tl;dr
at the end.
Although I have tweaked this over the years, the original code came from (I think, I've long since lost the bookmark) klymyshyn.com
Based off of a script by Adam Pierce. Mine is a little more user friendly.
Get latest version here.