Skip to content

Instantly share code, notes, and snippets.

@orientalperil
orientalperil / title.js
Created November 6, 2012 21:22
SelectWithOptgroups: a subclass of Ember.Select
App.SelectWithOptgroups = Ember.Select.extend({
// A version of Ember.Select that supports optgroup tags.
// content can contain objects that represent the options or the optgroups
// Example of an optgroup object:
// Ember.Object.create({
// optgroup_label: 'foo',
// content: [Ember.Object.create({label: 'First Name', value: 'first_name'}), Ember.Object.create({label: 'Last Name', value: 'last_name'})]
// })
defaultTemplate: Ember.Handlebars.compile('{{#if view.prompt}}<option>{{view.prompt}}</option>{{/if}}{{#each view.content}}{{#if optgroup_label}}<optgroup {{bindAttr label="optgroup_label"}}>{{#each content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}</optgroup>{{else}}{{view Ember.SelectOption contentBinding="this"}}{{/if}}{{/each}}'),
options: function() {
@orientalperil
orientalperil / bookmarklet.js
Created July 8, 2012 02:19 — forked from jonjaques/bookmarklet.js
jQuery Bookmarklet Template w/ Async Loading
// You create your bookmarklet by instantiating
// a new Bookmarklet function, then pass in the options like so.
// This example checks to see if the var is already defined, and makes
// sure not to overwrite it. This could happen if the user clicks on
// the bookmarklet more than once.
var MyBookmarklet = MyBookmarklet || new Bookmarklet({
// debug: true, // use debug to bust the cache on your resources
css: ['/my/style.css'],
js: [],
(function() {
/*global __fail__*/
if ('undefined' === typeof Ember) {
Ember = {};
if ('undefined' !== typeof window) {
window.Em = window.Ember = Em = Ember;
}
}
@orientalperil
orientalperil / ember_upgrade_flags.js
Created May 22, 2012 21:36
Ember.js upgrade flags
ENV = {};
ENV.CP_DEFAULT_CACHEABLE = true;
ENV.VIEW_PRESERVES_CONTEXT = true;
@orientalperil
orientalperil / simple_web_server.py
Created August 3, 2011 03:24
start a Web server to share the current directory
# start a Web server to share the current directory
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
@orientalperil
orientalperil / ack_sed.sh
Created February 18, 2011 08:04
use ack and sed to find and replace
ack --print0 -irl 'replace_me' location/ | xargs -0 -L1 sed -i '' 's/replace_me/with_me/g'