Skip to content

Instantly share code, notes, and snippets.

@heygrady
heygrady / jsonapi.json
Created January 5, 2017 20:08
Comparing generic WP-API response to JSONAPI
{
"data": {
"type": "page",
"id": "225",
"attributes": {
"slug": "about",
"title": "About",
"content": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In nec nunc molestie, pharetra tortor nec, tempus nisl. Sed mattis leo vitae imperdiet efficitur. Proin vitae nibh ante. Phasellus ut turpis vitae purus semper tincidunt. Donec sed elit neque. In in aliquam magna. Vivamus ex lorem, malesuada ut tincidunt id, tristique non est. Sed tempor lorem et sem finibus, ut tempor lacus mollis. Suspendisse ornare quis tellus ut convallis. Aliquam vestibulum ligula pulvinar, facilisis nibh lacinia, cursus est. Aenean eget rutrum metus. Suspendisse potenti. Nunc in condimentum lorem.</p>\n<p>Vivamus a laoreet augue. Etiam hendrerit metus nec sem tempus, a semper nisl dignissim. Duis tempor bibendum magna quis aliquet. Ut eget dui nec nisl feugiat eleifend. Nulla egestas volutpat nulla consectetur pharetra. Ut posuere, lorem sit amet volutpat interdum, ligula dolor tempus nisi, a t
{
"posts": {
"data": [
{
"id": 1,
"type": "posts",
"attributes": {
"title": "My title",
"content": "<p>Some markup in a string.</p>"
},
[
{
"id": 1,
"date": "2016-05-10T07:25:45",
"date_gmt": "2016-05-10T07:25:45",
"guid": {
"rendered": "https://demo.wp-api.org/?p=1"
},
"modified": "2016-05-10T07:25:45",
"modified_gmt": "2016-05-10T07:25:45",
import Ember from 'ember';
import SearchableSelect from 'ember-searchable-select/components/searchable-select';
import layout from './template';
const menuSelector = '.Searchable-select__options-list-scroll-wrapper';
export default SearchableSelect.extend({
layout,
classNames: ['Searchable-select-infinite'],

Model Buffered Proxy Mixin

Makes it easy to work with models through a buffered proxy. Designed to work with the model relationship mixins and supports an identical API for buffered relationship management. This builds on the functionality of the Ember Buffered Proxy library.

New States

Normally a model has two states:

  • Clean: no unsaved changes
  • Dirty: some unsaved changes

A buffered model has four states:

  • Clean: no unsaved changes

Model relationship mixins

Some mixins for managing model relationships.

  • belongsTo('this-model-name', 'to-model-name')
  • hasMany('this-model-name', 'has-model-name')
  • hasManyThrough('this-model-name', 'has-model-name', 'through-model-name')

The mixins are returned by factory functions that take standard arguments to create methods and properties based on the model names provided.

Example: Create Models

@heygrady
heygrady / .ruby-version
Last active November 19, 2023 04:43 — forked from mpapis/README.md
Example setup for running Unicorn on Ubuntu to manage Sinatra applications.
2.0.0@mygemset
@heygrady
heygrady / final.css
Created May 27, 2012 19:56
Adaptive Images with CSS
/* place these styles in your global stylesheet */
.image {
display: -moz-inline-box;
-moz-box-orient: vertical;
display: inline-block;
vertical-align: middle;
*vertical-align: auto;
font: 0/0 serif;
text-shadow: none;
color: transparent;
@heygrady
heygrady / fixed.css
Created April 22, 2012 06:14
Fluid Grid
#container {
width: 960px;
margin: 0 auto;
}
[role="main"] {
width: auto;
margin: 0 0;
}
(function(window, document, undefined){
"use strict";
// create a test element
var testElem = document.createElement('test'),
docElement = document.documentElement,
defaultView = document.defaultView,
getComputedStyle = defaultView && defaultView.getComputedStyle,
computedValueBug,
runit = /^(-?[\d+\.\-]+)([a-z]+|%)$/i,