Skip to content

Instantly share code, notes, and snippets.

View kevinansfield's full-sized avatar

Kevin Ansfield kevinansfield

View GitHub Profile
@kevinansfield
kevinansfield / video.rb
Created May 20, 2015 16:12
Refile attachment with ZenCoder processing
# == Schema Information
#
# Table name: videos
#
# id :integer not null, primary key
# meta_info :jsonb default({}), not null, indexed
# created_at :datetime not null
# updated_at :datetime not null
# videoable_id :integer indexed => [videoable_type]
# videoable_type :string indexed => [videoable_id]
class Scorecard::Cell < Cell::Concept
include ActionView::RecordIdentifier
def show
render
end
private
def competition_entry
class Scorecard::Cell < Cell::Concept
include ActionView::RecordIdentifier
...
class Form < Scorecard::Cell
include Cell::Erb
# include ActionView::Context
include ActiveSupport::Configurable
include ActionController::RequestForgeryProtection
<%= form_for form, url: form_url do |f| %>
<%= f.fields_for :moves do |m| %>
<%= m.hidden_field :move_id %>
<%= m.text_field :score %>
<% end %>
<%= f.submit 'Finish Judging' %>
<% end %>
> npm install -g repl-promised
> NODE_ENV=development node-promised
> var express     = require('express'),
    hbs         = require('express-hbs'),
    compress    = require('compression'),
    fs          = require('fs'),
@kevinansfield
kevinansfield / gist:d429317443355aa8b764
Created June 24, 2015 10:19
bookshelf.js - Selecting certain columns from associations
// Select specified columns on relations when fetching:
new models.Post({id:1}).fetch({
withRelated: [{'tags': function(qb) { qb.column('tags.id') }}]
}).then(function(post) {
return post.related('tags').toJSON()
})
=> [ { id: 1, parent: undefined } ]
// setup.hbs
{{#if stepOne}}
<ol>
<li class="active"><span class="step"><i class="icon-check"></i><span class="num">1</span></span></li>
<li><a class="step" {{action "toStepTwo"}}><i class="icon-check"></i><span class="num">2</span></a></li>
<li><span class="step"> <i class="icon-check"></i><span class="num">3</span></span></li>
</ol>
{{/if}
// {{#if stepTwo}}...
@kevinansfield
kevinansfield / gist:30e55556e17c10e082bd
Created October 15, 2015 12:07
Ghost ember test failures
not ok 5 PhantomJS 1.9 - Acceptance: Settings - Navigation when logged in clears unsaved settings when navigating away
---
message: >
Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun.
You will need to wrap any code with asynchronous side-effects in a run (http://localhost:7357/assets/vendor.js:14819)
Log: |
...
----
@kevinansfield
kevinansfield / index.hbs
Last active November 26, 2015 19:56
Sorting tags by number of authors using Ghost's sexy new {{#get}} helper and public API
<h1>Tags (by number of authors):</h1>
{{#get "tags" limit="all" as |tags|}}
<ul class="tags">
{{#each tags}}
<li class="tag" data-id="{{id}}">
{{name}} - <span class="author-count"></span> Authors
</li>
{{/each}}
</ul>
{{/get}}
@kevinansfield
kevinansfield / changelog.md
Last active July 27, 2016 14:36
Ghost 0.9.0 Changelog
  • e203eb8 Version bump to 0.9.0 - Kevin Ansfield
  • c6f1a8d fix: refresh settings cache for migration 006 (#7147) - Katharina Irrgang
  • e76d35d Upgrading Ghost-Admin to 0.9.0 - Kevin Ansfield
  • 5d2e020 Version bump to 0.9.0 - Kevin Ansfield
  • 502abeb Upgrading Casper to 1.3.1 - Kevin Ansfield
  • e5a0471 improvement: set activeTimezone when transforming dates (#7142) - Katharina Irrgang
  • 96f2d40 Handle automatic timezone override - Kevin Ansfield
  • c9dc367 improvement: validate timezones (#7143) - Katharina Irrgang
  • 417b9b6 fix: enable mai