Skip to content

Instantly share code, notes, and snippets.

@brianburridge
brianburridge / gist:11298396
Last active October 8, 2023 12:49
How to load MySQL time zone tables from Mac OS time zone files

The easiest way to load the Mysql Time Zone tables from your Mac OS time zone fields is via this command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

However, on many systems like mine that will fail because some of the time zone information is incompatible with the database schema for the time zone tables.

Therefore, you'll want to load the time zone information into a text file and edit it to only include the time zones you need. (Or, attempt to find the data breaking the import.)

mysql_tzinfo_to_sql /usr/share/zoneinfo > zone_import.sql
@brianburridge
brianburridge / wordpressxml2jekyll.rb
Last active June 23, 2023 15:38 — forked from rzhw/wordpressxml2jekyll.rb
Convert Wordpress xml export to Jekyll format using Markdown
#!/usr/bin/env ruby
# Input: WordPress XML export file.
# Outputs: a series of Markdown files ready to be included in a Jekyll site,
# and comments.yml which contains all approved comments with metadata which
# can be used for a Disqus import.
# Changes from the original gist: http://gist.github.com/268428
# 1. Handles titles containing special characters. Those have to be YAML escaped
# 2. Use the original permalinks in wordpress.
@brianburridge
brianburridge / gist:8d2755a73dd5b4f0332b
Created December 10, 2014 19:47
Export local db to JSON
namespace :json do
desc "Export all data to JSON files"
task :export => :environment do
Rails.application.eager_load!
ActiveRecord::Base.descendants.each do |model|
file = File.open(File.join(Rails.root, "db", "export", "#{model.table_name}.json"), 'w')
file.write model.all.to_json
file.close
end
@brianburridge
brianburridge / ruby_ftp_example.rb
Last active August 30, 2019 14:46 — forked from 3dd13/ruby_ftp_example.rb
Sample code of using Ruby Net::FTP library. Login to FTP server, list out files, check directory existence, upload files
require 'net/ftp'
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk"
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login"
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password"
# LOGIN and LIST available files at default home directory
Net::FTP.open(ENV['CONTENT_SERVER_DOMAIN_NAME'], ENV['CONTENT_SERVER_FTP_LOGIN'], ENV['CONTENT_SERVER_FTP_PASSWORD']) do |ftp|
ftp.login
jQuery(function ($) {
var show_error, stripeResponseHandler;
$(function() {
var $form = $('#new_chapter_payment');
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);
$form.find('.submit').prop('value', 'Submitting Payment...');
// Request a token from Stripe:
@brianburridge
brianburridge / gist:7362537
Last active December 27, 2015 17:29
Wifi, inefficiencies and a bizarre trip to the library

After dropping my son off at football practice, I attempted to work at Panera Bread for a bit today but the wifi was horribly slow. Sadly, my tethering was unable to bail me out this time because of the poor connection my phone was getting. I packed up and drove down the road to the library. Been meaning to try it anyway.

It's a nice new library. Very modern with all the newest amenities and in great condition. I attempted to use the wifi but it required a username and password. I inquired at the 'Information Desk' and was guided over to another desk to get a library card. Signing up for a card was in itself inefficient, as I had to both present my driver's license and enter the information from it onto another card. Really?

Once I had my new library card, with a password (never had a library card before that required a password) I went back to the information desk. Here I was told that I now had to get signed up for the wifi into a different system and then, an even more bizarre process was explained to me

@brianburridge
brianburridge / gist:5310983
Created April 4, 2013 14:48
Create a gemspec from the currently installed gems within a Heroku app
`gem list`.split("\n").each do |gem| a = gem.split(" ");puts "gem '#{a[0]}', '#{a[1].gsub(/[()]/, "")}'";end ;nil
@brianburridge
brianburridge / gist:3828703
Created October 3, 2012 18:11
Check Hash for key and append to it
if options.class != Hash
options = {class: "required"}
else
options[:class] = ((options[:class] || "") + " required").split(" ").uniq.join(" ")
end
@brianburridge
brianburridge / caveatPatchor.js
Created July 10, 2012 16:13
My Propane Customizations
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
def Tumblr.youtube_views(post)
begin
doc = Hpricot.parse(post)
video_count = 0
if doc.present?
embed_doc = doc.at("embed")
embed_doc = doc.at("iframe") if embed_doc.class != Hpricot::Elem
if !embed_doc.nil?
video_url = embed_doc.attributes["src"]
video_id = video_url.split("/")[4]