SSL - Generating an Unencrypted Key and Csr for a Cert Request

Had to generate a new ssh key and cert request the other day for a dreamhost server. Accidentally made the mistake of putting a passphrase on the key, so my first request came back no good.

Here is the script that I used to generate a new private key and csr request to submit to the certificate authority:

1
openssl req -nodes --newkey rsa:2048 --keyout new_key.key -out new_csr.csr

The -nodes argument is what ensures that the new private key will remain unencrypted, which is essential if you are installing the certificate on a web server through some sort of admin interface, vs having access to the box yourself.

Develop With Passion®

Speak Life

Our message series for this year in Church is all about “Mountains will move”.

One of the aspects that our pastor has talked about in the last couple of weeks (event though I’ve missed quite a bit this year!) is speaking to our mountains.

Our words have power, God’s word says:

The tongue has the power of life and death, and those who love it will eat its fruit.

When we choose to use our words to speak life into people as opposed to tearing them down, we can literally transform a heart.

This song is an awesome song that reminds me of the impact that “Speaking Life” can have.

Develop With Passion®

Unix Tool 1 - Nohup

This post, along with many others to come is serving as a pointer to people that I have worked/will work with about lots of useful unix utilities. Where there is an existing good reference I will just post a link, otherwise I’ll write my own post. Current time demands warrant that I’m going to be link posting a lot!!

The tools are not mentioned in any particular order, so don’t place any significance on which order I choose to mention them.

I am of the opinion that every developer owes it to themselves to get a grounding in unix and its accompanying toolchain, though that’s a discussion for a whole other blog post!

Following posts will be absent of the prior blurb and just get right to the tool.

nohup

Used to keep background jobs running when you exit from a shell session.

Develop With Passion®

Determine Which Process Is Using a Port

Quick bit of unix trivia!

Every so often I will be recreating one of my Vagrant vm’s, and even though it should have been destroyed I will get errors about forwarded ports colliding.

In this situation I want to verify that it is the vm provider that is locking the port (vmware fusion in my case).

To do that just run:

1
lsof -i :[port_number]

As an example (using port 80), this is the output I get:

1
2
3
4
COMMAND     PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
Dropbox     418   jp   23u  IPv4 0x3321ede7d20f87c3      0t0  TCP 192.168.1.2:49204->snt-re3-6c.sjc.dropbox.com:http (ESTABLISHED)
firefox   82810   jp   58u  IPv4 0x3321ede7e980cfab      0t0  TCP 192.168.1.2:60421->pb-in-f95.1e100.net:http (ESTABLISHED)
firefox   82810   jp   59u  IPv4 0x3321ede7eeddc7c3      0t0  TCP 192.168.1.2:60422->pb-in-f95.1e100.net:http (ESTABLISHED)

At that point I have the PID that I can then terminate expeditiously!!

Develop With Passion®

Updated TMUX, Regaining Splitting/creating New Windows Based on Current Directory

Just upgraded my copy of tmux and went to split my windows and realized that the default behaviour to split the window based on the current directory disappeared.

The quick fix to this for me (could be a better one, but I have not done any research yet) was to remap my map binding to augment the commands to maintain their old behaviour:

Updating Tmux split bindings
1
2
3
bind c new-window -c '#{pane_current_path}'
bind-key d split-window -v -c '#{pane_current_path}'
bind-key % split-window -h -c '#{pane_current_path}'

Each of these bindings maintain the exact same behaviour that was there prior to my tmux update.

Develop With Passion®

Run the Current File With an External Tool - Vim

There are lots of times when I am working with a file in vim that I want to be able to trigger an external tool against the current file.

Of course, I can drop to a shell or enter ex mode, but most of the time I would like to be able to just trigger a mapping that executes the external tool against the current file. An example of this would be editing a javascript file and being able to have it executed by nodejs, or editing a ruby file and being able to have it executed by the interpreter.

I set up the current script in my custom plugins folder (you can just place it in your .vimrc if you want a simple start):

1
2
3
4
5
6
7
8
9
if !exists("g:external_tool")
  let g:external_tool = "echo {current_file}"
endif

function! RunCurrentFileWithExternalCommand()
  let l:current_file = @%
  let l:command = "!clear && echo " . g:external_tool . " && " . g:external_tool
  execute substitute(g:external_tool, "{current_file}", l:current_file, "g")
endfunction

The following line:

1
let g:external_tool = "echo {current_file}"

Sets up an global external_tool variable that is initialized to the echo command (not immediately useful!). Notice the use of {current_file}, this is just a placeholder that will be replaced in a later substitution.

The RunCurrentFileWithExternalCommand function captures the name of the current file into the local variable current_file:

1
let l:current_file = @%

The @ operator lets you address the contents of a register. The % register is the register that contains the name of the current file being edited. The next line:

1
let l:command = "!clear && echo " . g:external_tool . " && " . g:external_tool

Sets up the command string that will be executed. The “.” is how you do string concatenation in vim. In this case, if the g:external tool variable is not changed, the default command that would be run is:

1
clear && echo "the_current_file_name" && echo [the_current_file_name]

Finally the substitute command is run to replace the {current_file} marker with the name of the current file, and then it is run through the execute command.

Here is an example of one of the mappings I have in place for a project I am currently working on:

1
nnoremap <Leader>rnv :let g:external_tool = "vagrant ssh -c \"cd app && node {current_file}\""<CR>

This command will run the current file I am editing against the vagrant instance that hosts the app and all of its dependencies. This allows my base machine to just be the editor.

Here are the remaining set of config I have for my vim setup to make this happen:

1
source ~/.vim_runtime/remaps.vim

All of my main key remappings are defined in this file, here is the mapping that I have in my vimrc file to run the current file with the currently configured external tool is:

1
2
3
4
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Running Current File
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Leader>rrf :wa<cr> :call RunCurrentFileWithExternalCommand()<cr>

With that setup, I can have folder specific mappings that alter the g:external_tool variable, and then I can always hit rrf to run the current file with the external tool.

Develop With Passion®