Skip to content

Instantly share code, notes, and snippets.

@jamesmk
jamesmk / Design-Week-Portland-Badge.html
Last active February 22, 2018 16:24 — forked from traviskochel/Design Week Portland Badge
Include this code on your page before the end </body> tag.
<!-- Begin Design Week Portland Badge -->
<style type="text/css">
#dwp-badge { margin:0px;padding:0px;background:transparent url(https://www.designweekportland.com/DWP-badge.png) no-repeat scroll 0px 0px;height:88px;right:0px;position:fixed;bottom:25px;width:98px;z-index:9999999 !important; }
#dwp-badge:hover { background-position:0px -88px !important; }
#dwp-badge a { margin:0px;padding:0px;display:block;height:88px;width:98px;text-indent:-9999px;border:none; }
</style>
<div id="dwp-badge"><a href="https://www.designweekportland.com" target="_blank">Design Week Portland</a></div>
<!--End Design Week Portland Badge-->
@jamesmk
jamesmk / convert_mysql_encoding.rb
Last active April 18, 2019 21:34
Rake task to convert MySQL DB's tables and columns to a specific encoding and collation.
namespace :db do
desc "Convers the encoding and collation of database, tables and columns."
task :convert_encoding, [:character_set, :collation] => :environment do |t, args|
args.with_defaults(character_set: 'utf8', collation: 'utf8_general_ci')
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.execute("ALTER TABLE `#{table}` CONVERT TO CHARACTER SET #{args.character_set} COLLATE #{args.collation};")
end
end
end
@jamesmk
jamesmk / devise_support.rb
Last active August 29, 2015 14:19
Devise sign in support helper
# provides a `login(user)` method that works for all controller, request and feature specs
# requires devise, rspec and capybara
#
# usage:
# def super_admin_login
# role = FactoryGirl.create(:role, name: 'super admin')
# user = FactoryGirl.create(:user, first_name: 'SuperAdmin', role: role)
# login(user)
# end
@jamesmk
jamesmk / gist:ebac91f8c58981d30f72
Created November 12, 2014 17:02
Codeship Wordpress deployment
TARGET=/path/to/theme
USER=deployuser
SERVER=ip.or.domain
PORT=port
cd ~/clone/
find . -type f -iname \*.coffee -delete
find . -type f -iname \*.scss -delete
find . -type f -iname \*.less -delete
find . -type f -iname \*.scssc -delete
find . -name .sass-cache -type d -exec rm -r {} +
@jamesmk
jamesmk / home.html.slim
Last active August 29, 2015 14:08
Content blocks schema
/ in ASP
.summary = @page.company_summary.content
.quote
= @page.quote.content
em = @page.quote_attribution.content
@jamesmk
jamesmk / gist:8118420
Created December 24, 2013 22:31
rails_admin ArgumentError (invalid date) gemfile.lock
GIT
remote: git://github.com/ryanb/cancan.git
revision: 4560928dc375f9b31de00381c98334eb6aabc4b9
specs:
cancan (1.6.10)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.12)
@jamesmk
jamesmk / gist:8118398
Created December 24, 2013 22:29
rails_admin ArgumentError (invalid date) trace
ArgumentError in RailsAdmin::MainController#edit
invalid date
Rails.root: /Library/WebServer/Documents/work/anchor_cms/_anchor_cms
Application Trace | Framework Trace | Full Trace
/Users/james/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/date.rb:1576:in `new_by_frags'
/Users/james/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/date.rb:1621:in `parse'
activesupport (3.1.12) lib/active_support/values/time_zone.rb:273:in `parse'
rails_admin (0.4.9) lib/rails_admin/config/fields/types/datetime.rb:49:in `parse_date_string'
@jamesmk
jamesmk / railsconf2013-slides.md
Last active December 17, 2015 03:38
RailsConf 2013 slides
@jamesmk
jamesmk / gist:3860572
Created October 9, 2012 18:33
Aloha Ruby Conf notes
@jamesmk
jamesmk / gist:3289782
Created August 7, 2012 22:02
js sluggify
var slugify = function(text) {
text = text.replace(/^\s+|\s+$/g, ''); // trim
text = text.toLowerCase();
// remove accents
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {