Skip to content

Instantly share code, notes, and snippets.

@tomdale
tomdale / gist:3981133
Last active November 26, 2019 21:19
Ember.js Router API v2

WARNING

This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!

It All Starts With Templates

An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.

<header>
@niklas
niklas / ember-data-create-error-handling.coffee
Created October 30, 2012 17:50
HowTo create a DS.Model from ember-data, handling server-side validation errors
# If we save a record using ember-data's RESTadapter, and it fails, Rails
# returns the validation errors of the model as JSON hash:
#
# {"errors":{"name":["may not be blank"]}}
#
# This patches the RESTadapter to add these errors to the invalid record. It
# can be removed when the following Pull Request was merged into ember-data:
# https://github.com/emberjs/data/pull/376
DS.RESTAdapter.reopen
@nicdaCosta
nicdaCosta / Grep.js
Last active March 9, 2024 13:39
Basic function that searches / filters any object or function and returns matched properties.
/*
Grep.js
Author : Nic da Costa ( @nic_daCosta )
Created : 2012/11/14
Version : 0.2
(c) Nic da Costa
License : MIT, GPL licenses
Overview:
Basic function that searches / filters any object or function and returns matched properties.
@kimsama
kimsama / Debug.cs
Created November 21, 2012 04:38
It overrides UnityEngine.Debug to mute debug messages completely on a platform-specific basis. [Edit] Added isDebugBuild property.
//#if UNITY_EDITOR
//#define DEBUG
//#endif
using UnityEngine;
using System.Collections;
using System;
using System.IO;
using System.Text.RegularExpressions;
using UnityEngineInternal;
@mnme
mnme / Default (OSX).sublime-keymap -- User
Last active November 13, 2017 16:37 — forked from Dayjo/Default (OSX).sublime-keymap -- User
Sublime Text 2 and 3: fix for OSX home/end keys, with selection support and command (super) key
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} },
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } },
{ "keys": ["super+end"], "command": "move_to", "args": {"to": "eof"} },
{ "keys": ["super+home"], "command": "move_to", "args": {"to": "bof"} },
{ "keys": ["super+shift+end"], "command": "move_to", "args": {"to": "eof", "extend": true} },
{ "keys": ["super+shift+home"], "command": "move_to", "args": {"to": "bof", "extend": true } },
@pingortle
pingortle / Texture2DStuff.cs
Created April 3, 2013 04:45
Some example snippets from around the web related to low-level XNA Texture2D manipulation.
//To convert a Texture2D to an Image :
public static System.Drawing.Image Texture2Image(Texture2D texture)
{
if (texture == null)
{
return null;
}
if (texture.IsDisposed)
@carolineschnapp
carolineschnapp / gist:5397337
Last active January 20, 2023 10:11
Sample JavaScript file added with ScriptTag resource. This sample file is meant to teach best practices. Your app will load jQuery if it's not defined. Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
/* Sample JavaScript file added with ScriptTag resource.
This sample file is meant to teach best practices.
Your app will load jQuery if it's not defined.
Your app will load jQuery if jQuery is defined but is too old, e.g. < 1.7.
Your app does not change the definition of $ or jQuery outside the app.
Example: if a Shopify theme uses jQuery 1.4.2, both of these statements run in the console will still return '1.4.2'
once the app is installed, even if the app uses jQuery 1.9.1:
jQuery.fn.jquery => "1.4.2"
$.fn.jquery -> "1.4.2"
*/
@Override
public Class<?> findClass(String name) throws ClassNotFoundException {
if (invalidClasses.contains(name)) {
throw new ClassNotFoundException(name);
}
Class<?> cachedClass = cachedClasses.get(name);
if (cachedClass != null) {
return cachedClass;
}
for (String st : classLoaderExceptions) {
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'
@mstevenson
mstevenson / SaveFBX.cs
Created August 5, 2013 20:05
ASCII FBX file exporter for Unity. Extracted from Michal Mandrysz's Unity Summer of Code 2009 external lightmapping project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
/*