Skip to content

Instantly share code, notes, and snippets.

@mrinterweb
mrinterweb / gist:7e23a153a47c25adba1d
Created September 16, 2014 23:44
Ember-data localforage record cache
App.Cache = Em.Object.extend
init: ->
@store = App.__container__.lookup('store:main')
# tries to load the results from localforage cache or from normal adapter
findAll: ->
localforage.getItem(@modelStr).then (cacheItems)=>
if Em.isEmpty(cacheItems)
@findAndCache()
else
@tim-evans
tim-evans / document_title.js
Created August 22, 2014 19:28
Document title mixin for Ember.Router
import Ember from "ember";
var get = Ember.get;
var copy = Ember.copy;
var removeObserver = Ember.removeObserver;
var addObserver = Ember.addObserver;
var DocumentTitleMixin = Ember.Mixin.create({
titleTokensDidChange: function () {
@aarongustafson
aarongustafson / getActiveMQ.js
Last active June 27, 2017 03:59
A simple way to track media query use in your JavaScript
// Get the active Media Query as defined in the CSS
// Use the following format:
// #getActiveMQ-watcher { font-family: "default"; }
// @media only screen and (min-width:20em){ #getActiveMQ-watcher { font-family: "small"; } }
// etc.
window.getActiveMQ = function() {
// Build the watcher
var $watcher = document.createElement('div'),
// alias getComputedStyle
computed = window.getComputedStyle,
@chriseidhof
chriseidhof / parsing.swift
Last active April 16, 2023 02:38
JSON Parsing in Swift
// This code accompanies a blog post: http://chris.eidhof.nl/posts/json-parsing-in-swift.html
//
// As of Beta5, the >>= operator is already defined, so I changed it to >>>=
import Foundation
let parsedJSON : [String:AnyObject] = [
"stat": "ok",
"blogs": [
@dbwhddn10
dbwhddn10 / SassMeister-input.scss
Created July 26, 2014 03:31
Generated by SassMeister.com.
// ----
// Sass (v3.3.10)
// Compass (v1.0.0.alpha.20)
// ----
// -----------------------------------------------------------------------------
// Introduction
// -----------------------------------------------------------------------------
// Here is hacky and experimental solution for cross-scopes extends
@bencates
bencates / svgtest.html
Created June 26, 2014 04:43
Draw a SVG hexagonal grid
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SVG Test</title>
</head>
<body>
<svg id="s" version="1.1"
width="300" height="300"
xmlns="http://www.w3.org/2000/svg">
@staltz
staltz / introrx.md
Last active May 28, 2024 17:42
The introduction to Reactive Programming you've been missing
@cyril-sf
cyril-sf / gist:515085e856f9dac2f06a
Last active November 13, 2015 22:29
Polymorphic hasMany w/ FixtureAdapter
var User = DS.Model.extend({
messages: DS.hasMany('message', {polymorphic: true})
});
var Message = DS.Model.extend({
user: DS.belongsTo('user'),
body: DS.attr()
});
var Post = Message.extend({
/* Put your CSS here */
html, body {
margin: 20px;
}
.color {
height: 200px;
width: 200px;
}
@xypaul
xypaul / template.hbs
Created May 8, 2014 01:50
Vis.js Graph as Ember Component
<!-- Setting up component -->
<script type="text/x-handlebars" id="components/vis-editor"></script>
<!-- Example of using component -->
<script type="text/x-handlebars" id="application">
{{viz-editor data=data selected=selected editing=editing}}
</script>