Skip to content

Instantly share code, notes, and snippets.


Christopher Milne christophermlne

View GitHub Profile
christophermlne / example.rb
Created Jun 27, 2018
Ruby function to find a valid encoding for a text file
View example.rb
def open_text_file_with_valid_encoding!(file_path, encoding='UTF-8')
# Tries to find a valid encoding for a text file.
# Converts return value to UTF-8.
encodings = ['UTF-8', 'ISO-8859-1']
contents =, "r:#{encoding}") { |file| }
unless contents.valid_encoding?
if next_encoding = encodings[encodings.index(encoding) + 1]
puts "Warning: Encoding #{encoding} for #{file_path} is not valid. "\
christophermlne / make-chrome-accept-self-signed-ssl-cert.txt
Created Dec 5, 2016
Make Chrome accept self-signed ssl root cert
View make-chrome-accept-self-signed-ssl-cert.txt
ex +'/BEGIN CERTIFICATE/,/END CERTIFICATE/p' <(echo | openssl s_client -showcerts -connect -scq > file.crt
^^ add this file to OS keychain
christophermlne /
Last active Sep 9, 2015
The exact same command entered twice for npm—with two different results!

$ ember install emberx-select
version: 0.2.7 1.13.8

Installed packages for tooling via npm.
Install failed. Could not find addon with name: emberx-select

$ ember install emberx-select
version: 0.2.7

christophermlne / fancy-markup.rb
Created Apr 30, 2015
Toronto Ruby Brigate: DSL Workshop Solution, April 29 2015
View fancy-markup.rb
class FancyMarkup
def initialize
def method_missing(name, attr={}, &block)
puts "<#{name}#{self.flatten(attr)}>"
puts "</#{name}>"
christophermlne / file1.txt
Created Aug 13, 2014
test of create_gist
View file1.txt
test content
christophermlne / gist:2e646cf1da5e5f3b80be
Created Jun 9, 2014
Virtual Box Modern IE networking share localhost
View gist:2e646cf1da5e5f3b80be
Edit the hosts file: C:\windows\system32\drivers\etc\hosts
(if the hosts folder/file is invisible, select 'all files' from the file type dropdown)
Add this entry: localhost mydomain
You can now refer to the parent machine's vhosts by name!
christophermlne / WP Database Export
Last active Dec 22, 2015
Export wordpress database
View WP Database Export
mysqldump -u root -proot dbname > filename-$(date '+%Y%m%d-%H-%M').sql
View Wordpress child theme boilerplate
Theme Name: My Thematic Child Theme
Theme URI:
Description: This is a child theme of thematic created by me
Author: Abbas Suterwala
Author URI:
Template: thematic
Version: 1.0