Skip to content

Instantly share code, notes, and snippets.

@wmill
wmill / peepcode-ember-1.0-fix.diff
Last active December 23, 2015 02:29
This is a update for the "Fire Up Ember.js" screencast from peepcode. It makes things work with Ember.js 1.0. Apply to app.js and update the js file links in index.html. Tested with the following: Ember.VERSION : 1.0.0 Handlebars.VERSION : 1.0.0 jQuery.VERSION : 1.9.1 Ember Data VERSION : v1.0.0-beta.2
--- peepcode-ember-final/js/app.js 2013-02-23 00:37:57.000000000 -0500
+++ peepcode-ember-starter-app/js/app.js 2013-09-14 20:50:24.000000000 -0400
@@ -17,13 +17,13 @@
App.ApplicationRoute = Ember.Route.extend({
setupController: function() {
- this.controllerFor('food').set('model', App.Food.find());
+ this.controllerFor('food').set('model', this.store.find('food'));
}
});
@wmill
wmill / people.json
Created April 13, 2013 19:04
This JSON validates, works in Firefox and Safari, but dies in Chrome
[
{
"created_at": "2012-12-07T07:15:00Z",
"first_name": "Janice",
"id": 1,
"last_name": "Resnick",
"riding": "Ajax--Pickering",
"updated_at": "2012-12-07T07:15:00Z"
},
{
$.getJSON("http://www.reddit.com/r/" + subreddit + "/.json?jsonp=?").then(function(response) {
var links = [];
response.data.children.forEach(function (child) {
links.push(App.RedditLink.create(child.data));
});
return links;
}).then(function(data){
console.log(data)}
);
App.RedditLink.reopenClass({
/* Use the Reddit JSON API to retrieve a list of links within a subreddit. Returns
a promise that will resolve to an array of `App.RedditLink` objects */
findAll: function(subreddit) {
return $.getJSON("http://www.reddit.com/r/" + subreddit + "/.json?jsonp=?").then(function(response) {
var links = [];
response.data.children.forEach(function (child) {
links.push(App.RedditLink.create(child.data));
App.RedditLink = Ember.Object.extend({
/*
It seems reddit will return the string 'default' when there's no thumbnail present.
This computed property will convert 'default' to null to avoid rendering a broken
image link.
*/
thumbnailUrl: function() {
var thumbnail = this.get('thumbnail');
return (thumbnail === 'default') ? null : thumbnail;
<section id="todoapp">
<header id="header">
<h1>todos</h1>
{{view Ember.TextField id="new-todo" plaseholder="What needs to be done?" valueBinding="newTitle" action="createTodo"}}
</header>
{{#if length}}
<section id="main">
<ul id="todo-list">
{{#each filteredTodos itemController="todo"}}
<li {{bindAttr class="isCompleted:completed isEditing:editing"}}>
$('.nav-button').on('click', function(e){
//clear div, insert loading spinner
$content_div.html(spinner_html);
$.ajax({
url: $(this).data('ajax-url'),
success: function(data){
$('#the-fucking-spinner').remove();
$content_div.append(data);
}
@wmill
wmill / merzo_drag.user.js
Created March 6, 2012 19:36
Attempts to add multi browser dragging to merzo.net
// ==UserScript==
// @name Merzo Drag
// @namespace https://gist.github.com/raw/1988543/merzo_drag.user.js
// @include http://merzo.net/*
// @include http://*.merzo.net/*
//
//
// ==/UserScript==
//
@wmill
wmill / HelloWorld.java
Created January 30, 2012 17:47
Sun's example code, proof that coders love lawyers.
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
@wmill
wmill / github_anonymizer.user.js
Last active September 27, 2015 11:28
Greasemonkey GitHub Anonymizer, hides full names and photos so you won't be influenced by a potential candidate's name or appearance.
// ==UserScript==
// @name GitHub Anonymizer
// @namespace https://gist.github.com/raw/1262754/github_anonymizer.user.js
// @include http*://github.com/*
//
//
// ==/UserScript==
//