Wednesday, April 01, 2015

Upgrade to Cedar 14 on Heroku

Use with caution, this does not test to be sure your app will work with the new stack:
$ heroku stack:set cedar-14
$ git commit --allow-empty -m "Upgrading to Cedar-14"
$ git push heroku master

You can rollback with:

$ heroku releases
$ heroku rollback [previous release]
$ heroku stack:set cedar

[previous release] is a release number like v12 taken from the output of the heroic releases command.

From: https://devcenter.heroku.com/articles/cedar-14-migration

Generate a new CSR from existing CRT and KEY

$ openssl x509 \
       -in domain.crt \
       -signkey domain.key \
       -x509toreq -out domain.csr

Tuesday, March 31, 2015

APIs (useful links)

Use this to get a handle on using it with curl
https://gist.github.com/caspyin/2288960

Once you have that down use this to figure out the JSON data structure for your GET/POST requests
https://www.getpostman.com/

Great tutorial on creating you own API in a few minutes with node. (I used coffee script)
https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4

Great site for converting js into coffee script
http://js2.coffee

Great writeup on API authentication (with code samples) I used the basic auth with ssl.
https://stormpath.com/blog/the-problem-with-api-authentication-in-express/

Monday, February 10, 2014

My ssh protocol handler for Firefox and under Linux

#!/bin/bash
address=`echo $1 | sed -e "s/ssh:\/\///" | sed -e "s|:....||"`
str=$1
n=4
port=`echo ${str:${#str} - $n}`
gnome-terminal -e "ssh ${address} -p ${port}"



Put this in a file and set it as executable. I put mine in ~/.bin/sshhandler
(chmod +x ~/.bin/sshhandler)
in firefox go to about:config
add new boolean value called
network.protocol-handler.expose.ssh

Set it to false.

In Firefox navigate to an ssh:// url and select the script as the application to handle them.

This should handle urls formatted in the following manner:

ssh://user@hostname:port


Friday, February 07, 2014

Change file extension for a batch of files

for files in *.txt
do
 mv "$files" "${files%.txt}.csv"
done

Friday, January 31, 2014

Online expanding of a VMWare linux server LVM Volume

Add the hard drive to the running VM.

dmesg (figure out what the device name is for the new device like /dev/sdf)
parted /dev/sdf

mklabel msdos (inside parted)
quit (inside parted)

pvcreate /dev/sdf
vgextend VolGroup00 /dev/sdf
lvextend /dev/mapper/VolGroup00-LogVol00 /dev/sdf
resize2fs /dev/mapper/VolGroup00-LogVol00 

Thursday, January 30, 2014

Compress and transfer in one step

This command uses tar to compress a directory and store it into a file located on a remote system. Handy.
$ tar vzcf - /path/to/data | ssh user@remotesvr `cat - > /backups/data.tgz`

Pure command line if then without the if or then

The && and || can be used to control command flow like if then...
$ /use/bin/somecmd && echo "it worked!" || echo "epic fail!"

Process list filtering with grep

Adding the square brackets prevents the grep command from showing up in the process list.

$ ps -ef | grep proces[s]

Icinga log parsing perl command

The perl command changes unix time to human readable time in the output... Very useful for searching the check log archives.

more /usr/local/icinga/var/archives/* | perl -p -e 's/^\[(\d+)\]/"[". localtime($1) . "]"/e' | grep <what you're looking for>