Skip to content

Instantly share code, notes, and snippets.

<script src="http://assets.sbnation.com/features/2013-NHL-Preview/tentpole.min.js"></script>
<script type="text/javascript"><!--
jQuery(function($) { $('.feature-body').css("height",$(window).height()) });
// --></script>
select billings.cost, employees.name
from (
select cost, employee_id from past_billings
union
select (hours * rate) as cost from future_billings
) billings
join employees on employees.id = billings.employee_id;
@thomsbg
thomsbg / gist:7216377
Created October 29, 2013 15:04
Left outer join + if statement
select stuff.*, if(
exchange_rate.rate is null,
(select rate from exchange_rates order by month desc limit 1),
exchange_rate.rate
)
from stuff
left outer join exchange_rate on exchange_rate.stuff_id = stuff.id;
(
select transactions.*, exchange_rate.rate
join exchange_rate on transcations.month = exchange_rate.month
)
union
(
select predictions.*, (select rate from exchange_rate order by month desc limit 1) as rate
)
@thomsbg
thomsbg / gist:8847050
Created February 6, 2014 16:00
each_slice
<% data.stories.each_slice(4) do |chunk| %>
<div class="m-box">
<% chunk.each do |d| %>
<div class="m-boxes__quarter" style="background-image: url('<%= d.image %>');">
<h6><a href="<%= d.url %>" target="new"><%= d.headline %></a></h6>
</div>
<% end %>
</div>
<% end %>
<div style="width: 970px; margin: 0 auto; clear: both;">
<!-- ad markup goes here -->
</div>
@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>
@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 / 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 / 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) {