@ wrote... (8 months, 3 weeks ago)

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
Category: tech, Tags: linux, shell
Comments: 0
@ wrote... (9 months, 4 weeks ago)

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}
Category: tech, Tags: linux, python, shell
Comments: 0
@ wrote... (2 years ago)

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]
$

more…

Category: tech, Tags: shell
Comments: 1
@ wrote... (3 years, 6 months ago)

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
Category: tech, Tags: shell
Comments: 0
@ wrote... (5 years, 7 months ago)

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

more…

Category: tech, Tags: python, shell
Comments: 10
@ wrote... (7 years ago)

Based off of a script by Adam Pierce. Mine is a little more user friendly.

Get latest version here.

more…

Category: tech, Tags: shell
Comments: 0
@ wrote... (10 years, 10 months ago)

Some useful Linux commands.

more…

Category: tech, Tags: linux, shell
Comments: 0