Skip to content

Instantly share code, notes, and snippets.

View christophermlne's full-sized avatar

Christopher Milne christophermlne

View GitHub Profile
@christophermlne
christophermlne / example.rb
Created June 27, 2018 01:03
Ruby function to find a valid encoding for a text file
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 = File.open(file_path, "r:#{encoding}") { |file| file.read }
unless contents.valid_encoding?
if next_encoding = encodings[encodings.index(encoding) + 1]
puts "Warning: Encoding #{encoding} for #{file_path} is not valid. "\
@christophermlne
christophermlne / make-chrome-accept-self-signed-ssl-cert.txt
Created December 5, 2016 13:46
Make Chrome accept self-signed ssl root cert
ex +'/BEGIN CERTIFICATE/,/END CERTIFICATE/p' <(echo | openssl s_client -showcerts -connect example.com:443) -scq > file.crt
^^ add this file to OS keychain
http://superuser.com/questions/1004794/how-to-always-allow-insecure-connection-for-a-certain-url-in-chrome
@christophermlne
christophermlne / the-problem-with-npm.md
Last active September 9, 2015 21:12
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
christophermlne / fancy-markup.rb
Created April 30, 2015 13:57
Toronto Ruby Brigate: DSL Workshop Solution, April 29 2015
class FancyMarkup
def initialize
end
def method_missing(name, attr={}, &block)
puts "<#{name}#{self.flatten(attr)}>"
self.instance_eval(&block)
puts "</#{name}>"
@christophermlne
christophermlne / file1.txt
Created August 13, 2014 01:56
test of create_gist
test content
@christophermlne
christophermlne / gist:2e646cf1da5e5f3b80be
Created June 9, 2014 15:29
Virtual Box Modern IE networking share localhost
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:
10.0.2.2 localhost mydomain mydomain.com
You can now refer to the parent machine's vhosts by name!
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
@christophermlne
christophermlne / WP Database Export
Last active December 22, 2015 05:49
Export wordpress database
mysqldump -u root -proot dbname > filename-$(date '+%Y%m%d-%H-%M').sql
@christophermlne
christophermlne / Wordpress child theme boilerplate
Created August 27, 2013 19:15
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
*/