Skip to content

Instantly share code, notes, and snippets.

@joelcox
joelcox / controllers.application.js
Last active January 23, 2020 19:27
setInterval DOM
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super();
this.set('model', [1, 2, 3]);
setInterval(() => {
console.log(Math.random());
@joelcox
joelcox / index.html
Created April 9, 2019 13:24
RobinHQ Ember
index.
<ul class="main-navigation">
<li class="main-navigation__menu-item main-navigation__menu-item--active">
<span class="main-navigation__menu-item-title">Want this</span>
</li>
<li class="main-navigation__menu-item main-navigation__menu-item--active">
<span class="main-navigation__menu-item-title main-navigation__menu-item--active-title">Not this</span>
</li>
</ul>
@joelcox
joelcox / highlight.swift
Created September 23, 2015 18:41
Swift implementation to highlight Cocoa UI elements (http://stackoverflow.com/a/25984748/316803)
NSColor.selectedMenuItemColor().set()
NSRectFillUsingOperation(dirtyRect, .CompositeSourceOver);
if (dirtyRect.size.height > 1) {
let heightMinus1 = dirtyRect.size.height - 1
let currentControlTint = NSColor.currentControlTint()
var startingOpacity: CGFloat = 0.09
if currentControlTint == .BlueControlTint {
startingOpacity = 0.16
@joelcox
joelcox / schedule.md
Last active August 29, 2015 14:16
Cycling calendar 2015

Spring classics

  • Feb 28 (Sat) - Omloop Het Nieuwsblad
  • Paris – Nice
  • Mar 22 (Sun) - Milan – San Remo
  • Mar 27 (Fri) - E3 Harelbeke
  • Mar 29 (Sun) - Gent–Wevelgem
  • Apr 5 (Sun) - Tour of Flanders
  • Apr 12 (Sun) - Paris – Roubaix
@joelcox
joelcox / resource-options.json
Created February 23, 2015 14:18
Resource options request
GET http://localhost:5000/orders/4
{
"status": "shipped"
}
OPTIONS http://localhost:5000/orders/4
{
"PUT": {
"description": "Modify the status of a shipped order",
"parameters": {
@joelcox
joelcox / resource-download.json
Created February 23, 2015 13:58
Resource download request
GET http://localhost:5000/articles/8
Content-Type: application/pdf
@joelcox
joelcox / resource-action.json
Last active August 29, 2015 14:15
Resource action request
PATCH http://localhost:5000/comments/1
{
"favorite": true
}
@joelcox
joelcox / promise-parallel.js
Last active August 29, 2015 14:15
Parallel promises
actions: {
submitForm: function() {
var model = this.store.createRecord('post');
this.resolveKeywords(controller.get('postKeywords')).then(function(keywords) {
model.get('keywords').pushObjects(keywords);
return model.save();
}).then(function() {
controller.transitionToRoute('post', model);
});
@joelcox
joelcox / promise-chained.js
Last active August 29, 2015 14:15
Chained promises
promise.then(function(response) {
console.log(response);
return promise;
}).then(function(anotherResponse) {
console.log(anotherResponse);
}).catch(function(error) {
console.error(error);
});