Skip to content

Instantly share code, notes, and snippets.

diff --git a/config/schema/rich-text.json b/config/schema/rich-text.json
index 945b771d2..385e33e8a 100644
--- a/config/schema/rich-text.json
+++ b/config/schema/rich-text.json
@@ -88,7 +88,19 @@
"type": "integer"
},
"attributes": {
- "$ref": "#/attributes"
+ "oneOf": [
diff --git a/shared/find_each_model.js b/shared/find_each_model.js
index fb575db..bb671c8 100644
--- a/shared/find_each_model.js
+++ b/shared/find_each_model.js
@@ -1,10 +1,12 @@
var Bluebird = require('bluebird');
-module.exports = function findEach(Model, fn, since, success) {
- since = (since == null) ? 0 : since;
+module.exports = function findEach(Model, fn, lastId, success) {
@thomsbg
thomsbg / mysql.log
Last active October 21, 2016 00:11
# at 76104583
#161020 20:30:26 server id 211 end_log_pos 76104666 CRC32 0xccbca688 Query thread_id=878921 exec_time=0 error_code=0
SET TIMESTAMP=1476995426/*!*/;
BEGIN
/*!*/;
# at 76104666
#161020 20:30:26 server id 211 end_log_pos 76121710 CRC32 0x27a99c3e Query thread_id=878921 exec_time=0 error_code=0
SET TIMESTAMP=1476995426/*!*/;
update `docs` set `head_version` = '{\"doc_id\":154345,\"user_id\":44,\"delta\":[{\"p\":[\"publish_history\",2],\"li\":{\"date\":\"2016-10-20T20:30:23.628Z\",\"user\":\"David Fucillo\",\"event_type\":\"published\"}}],\"contents\":{\"hed\":{\"ops\":[{\"attributes\":{\"author\":\"44\"},\"insert\":\"Jameis \"},{\"insert\":\"Winston on why he didn’t go to Stanford: “It was really me not really knowing how prestigious Stanford was.”\\n\",\"attributes\":{\"author\":\"1627\"}}]},\"dek\":{\"ops\":[{\"insert\":\"The Tampa Bay Buccaneer\",\"attributes\":{\"author\":\"1627\"}},{\"insert\":\"s\",\"attributes\":{\"author\":\"44\"}},{\"insert\":\" quarterback met with the Bay Area media,
@thomsbg
thomsbg / snippet.rb
Created November 19, 2015 00:02
fix_nested_attributes_for_uniqueness.rb
def fix(records, params, matcher)
params = params.deep_dup
records.each do |record|
if p.any? { |attrs| attrs['id'].present? && attrs['id'].to_i == record.id }
next
elsif (new_attrs = p.detect { |attrs| attrs['id'].blank? && attrs[matcher].present? && attrs[matcher].to_i == record[matcher] })
new_attrs['id'] = record.id
else
p << { '_destroy' => true, 'id' => record.id }
@thomsbg
thomsbg / image.js
Created August 23, 2015 22:07
image quill format
{
type: 'embed',
tag: 'IFRAME',
add: function(node, value) {
node.classList.add('image');
node.setAttribute('data-src', value.src);
node.setAttribute('data-caption', value.caption);
node.setAttribute('src', '/iframe/image.html');
return node;
},
@thomsbg
thomsbg / pullquote.js
Last active August 29, 2015 14:28
pullquote quill format
{
type: 'embed',
tag: 'IFRAME',
add: function(node, data) {
node.classList.add('pullquote');
node.setAttribute('data-pullquote', data.value);
node.setAttribute('src', '/iframe/pullquote.html');
return node;
},
remove: function(node) {
@thomsbg
thomsbg / rich-text-schema.yml
Created March 3, 2015 22:16
rich-text json-schema
$schema: 'http://json-schema.org/draft-04/schema#'
type: object
properties:
ops:
type: array
items:
oneOf:
- type: object
properties:
insert:
@thomsbg
thomsbg / snippet.json
Created September 11, 2014 18:14
content model
{
"startLength": 0,
"endLength": 394,
"ops": [
{
"value": "Quill Rich Text Editor",
"attributes": {
"size": "18px"
}
},
@thomsbg
thomsbg / index.html
Last active August 29, 2015 14:01
Mid-body ad unit test bookmarklet
<a href="javascript:(function($) {var ad = $('<p>').css({ backgroundColor: 'red', height: '0' }); $('#article-body, .entry-body').first().find('p, h1, h2, h3, h4, h5, h6, blockquote').eq(2).before(ad); ad.animate({ height: '250px' }, 'fast'); })(jQuery)">Test mid-body ad</a>
<p>^---- Drag this to your bookmarks toolbar.</p>
<p>Click it on any chorus article page to insert a red box where the ad would appear.</p>
<div style="width: 970px; margin: 0 auto; clear: both;">
<!-- ad markup goes here -->
</div>