Skip to content

Instantly share code, notes, and snippets.

View tfentonz's full-sized avatar

Tom Fenton tfentonz

  • MAGIQ Software
  • Christchurch, New Zealand
  • 23:23 (UTC +12:00)
  • LinkedIn in/tfentonz
View GitHub Profile
@tfentonz
tfentonz / default.js
Created August 16, 2012 02:45
dotjs to remove any password input onpaste events
// remove any password input onpaste events
$('input:password[onpaste]').each(function() {
$(this).attr('onpaste', '');
});
@tfentonz
tfentonz / term132.sh
Created May 14, 2014 20:40
Resize Terminal window to 132 columns and 24 rows.
#!/bin/bash
printf "\e[8;24;132;t"
exit 0
@tfentonz
tfentonz / append_line.rb
Last active August 29, 2015 14:03
Append a fixed width format line to keywords file.
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
def keywords_file
ENV['PJKKG'] + '01'
end
def keywords_line(project)
@tfentonz
tfentonz / gist:3bb97fc2f39ea1e72a3a
Created May 26, 2015 03:24
Convert string with comma separated integers with spaces to an array of integers
"123, 45 6, 7 89".delete(' ').split(',').map(&:to_i)
# => [123, 456, 789]
@tfentonz
tfentonz / regex-one-liners.md
Created August 11, 2015 04:39
Regular expression one-liners

Replace Ruby 1.8 hash syntax in Vim.

%s/([^:]):(\w\w*)\s*=>\s*/\1\2: /g

@tfentonz
tfentonz / cars.sql
Created August 18, 2015 00:04
Test MySQL ALTER TABLE for timestamp column.
drop table if exists `cars`;
create table `cars` (
`id` int not null auto_increment,
`make` varchar(255),
`model` varchar(255),
`created_at` timestamp default current_timestamp not null,
`updated_at` timestamp default current_timestamp on update current_timestamp not null,
primary key (`id`)
);
@tfentonz
tfentonz / mysql_get_format.txt
Created January 11, 2016 02:01
MySQL GET_FORMAT
SELECT
NOW() AS 'now',
GET_FORMAT(DATE, 'ISO') AS 'format',
DATE_FORMAT(NOW(), GET_FORMAT(DATE, 'ISO')) AS 'iso_8601';
+---------------------+----------+------------+
| now | format | iso_8601 |
+---------------------+----------+------------+
| 2016-01-11 12:34:56 | %Y-%m-%d | 2016-01-11 |
+---------------------+----------+------------+
1 row in set (0.00 sec)
var date = new Date();
var dateString = [date.getFullYear(),
('0' + (date.getMonth() + 1)).slice(-2),
('0' + date.getDate()).slice(-2)].join('/');
dateString += ' ';
dateString += [('0' + date.getUTCHours()).slice(-2),
('0' + date.getUTCMinutes()).slice(-2),
('0' + date.getUTCSeconds()).slice(-2)].join(':');
dateString += ' +' + ((date.getTimezoneOffset() / 60) * -100);
@tfentonz
tfentonz / ssh_commands.md
Last active August 10, 2016 01:30
SSH Commands

SSH Commands

ssh-add

Add private key identities to the authentication agent storing passphrase in your keychain.

ssh-add -K ~/.ssh/some-key

ssh-keygen

@tfentonz
tfentonz / aws-server-certs.md
Last active February 14, 2017 02:54
AWS Server Certificates

AWS Server Certificates

The PFX format is not supported by AWS IAM. Follow the below steps to convert to the correct format (X5.09 PEM) by using OpenSSL.

unzip -j -P password Wildcard\ Completed\ Certificates\ for\ Import.zip

Extract private key

openssl pkcs12 -in wildcard.marlborought.govt.nz_withPK.pfx -nocerts -nodes -passin pass:goodsecret | openssl rsa -out my-private-key.pem