This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DraftContentItem.where(publishing_app: "email-campaign-frontend").each do |content_item| | |
content_item.update_attributes!(publishing_app: "share-sale-publisher") | |
payload = Presenters::ContentStorePresenter.present(content_item) | |
ContentStoreWorker.perform_async( | |
content_store: Adapters::DraftContentStore, | |
base_path: content_item.base_path, | |
payload: payload, | |
) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
require 'json' | |
buff = '' | |
open('https://api.github.com/repos/alphagov/smart-answers/pulls') { |f| f.each_line { |line| buff << line } } | |
pulls = JSON.parse(buff) | |
puts pulls.first['user'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["RAILS_ENV"] = "test" | |
require File.expand_path('../../config/environment', __FILE__) | |
require File.dirname(__FILE__) + '/blueprints' | |
require 'faker' | |
require 'rails/test_help' | |
require 'minitest/autorun' | |
require 'minitest/pride' | |
class MiniTest::Unit::TestCase | |
include MiniTest::ActiveRecordAssertions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rack::Parser, :content_types => { | |
'application/json' => Proc.new { |body| ::MultiJson.decode body } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MiniTest | |
module Assertions | |
module ActiveRecord | |
# assert_association User, :has_many, :editables, :polymorphic => true | |
# | |
def assert_association(clazz, association, associate, options={}) | |
reflected_assoc = clazz.reflect_on_association(associate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Passenger Ruby 1.9.3 Mysql AR create | |
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Server Software: Apache/2.2.14 | |
Server Hostname: perf-test.local | |
Server Port: 80 | |
Document Path: /message | |
Document Length: 0 bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Encryption = (function() { | |
function generateKey(seed) { | |
var key = "" | |
while (key.length < seed) key += Math.srand(seed) | |
return key | |
} | |
/* | |
* @param 'val' - a String to encode or a byte[] to decode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Given the String "Foo.who.bar" this function returns the function bar() from the context of Foo.who | |
* handy when you need to call or apply a namespaced function from a String representation. | |
*/ | |
var stringToFunction = function(str) { | |
var nsArr = str.split("."), | |
parentNs = window, | |
len = nsArr.length; | |
for (var idx = 0; idx < len; idx++) { | |
parentNs = parentNs[nsArr[idx]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.observe("dom:loaded", function() { | |
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; | |
var dateEl = $('project_expiry_date_3i'); | |
var monthEl = $('project_expiry_date_2i'); | |
var yearEl = $('project_expiry_date_1i'); | |
if (dateEl && monthEl && yearEl) { | |
var currentDateIndex = dateEl.selectedIndex; | |
function leapYearAdjustedDays() { | |
var daysInMonth = DAYS_IN_MONTH[monthEl.selectedIndex]; | |
// Leap year calc. |
NewerOlder