Skip to content

Instantly share code, notes, and snippets.

test
@ericmason
ericmason / mysql_convert_to_utf8.rb
Last active August 29, 2015 14:17
Change MySQL columns to UTF-8 without changing their values
#!/usr/bin/env ruby
##
# Change the type of MySQL columns that contain UTF-8 data to UTF-8 without changing their values
#
# Converts the columns to binary, then converts them back to char/text with the utf8 charset
# This is useful when the database has some other default value like latin1 but you've been
# storing values as UTF-8
##
### Keybase proof
I hereby claim:
* I am ericmason on github.
* I am ericmason (https://keybase.io/ericmason) on keybase.
* I have a public key whose fingerprint is 2E19 21D5 9F6E D235 C2E7 40C9 560F EBC4 A2E1 2685
To claim this, I am signing this object:
@ericmason
ericmason / word_mail_merge.rb
Created October 28, 2013 16:52
word_mail_merge.rb is a simple way to do mail merge in ruby
#!/usr/bin/env ruby
require 'zip/zip' # rubyzip gem
require 'nokogiri'
class WordMailMerge
def self.open(path, &block)
self.new(path, &block)
end
def force_settings
@replace["word/settings.xml"] = %{<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:settings xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:sl="http://schemas.openxmlformats.org/schemaLibrary/2006/main"><w:zoom w:percent="100"/></w:settings>}
end