Skip to content

Instantly share code, notes, and snippets.

@joliss
joliss / gist:3341227
Created August 13, 2012 14:28
Part of my generator script for .bashrc.generated, which is sourced from .bashrc. Allows running slow commands (lots of external calls, like `which`, etc.) without slowing shell startup.
expand_source() {
perl -p -e 's/^source ["'\'']?(.*?)["'\'']?$/`cat $1`/em'
}
(
...
test -f "`which rbenv`" && rbenv init - --no-rehash | expand_source
) > ~/.bashrc.generated
@joliss
joliss / gist:3414141
Created August 21, 2012 10:07
Trying to reproduce a flickering Capybara test with selenium-webdriver
require 'rubygems'
require 'selenium-webdriver'
path = File.expand_path("test.html")
File.open(path, "w") do |io|
io << <<EOF
<!DOCTYPE html>
<html>
<head>
class Blog
def comments
posts.map(&:comments).flatten
end
end
# Implementing the `comments` property in CoffeeScript.
# Note the lack of `flatten` and the heavy guarding
# against objects being undefined.
App.Blog = Ember.Object.extend
comments: (->
# Return all comments of all posts by flattening.
   (@get('[email protected]') ? []).reduce (a, b) ->
# b is a lazy hasMany collection of comments, so we must cast to array.
(a ? []).concat((b ? []).toArray())
@joliss
joliss / gist:3901862
Created October 16, 2012 20:43
Ember debugging pains

(Note: This gist is meant as a conversation-starter for Ember.js contributors. If you are getting started with Ember and are looking for pointers on how to debug Ember apps, check out Tom's talk instead.)

Let me demonstrate why debugging Ember applications is currently harder than it would ideally be.

Say you have a view somewhere on a page that contains

User name: "{{view.user.name}}"

And it renders User name: "". How do you find out what's going wrong?

@joliss
joliss / notes.md
Last active May 21, 2018 18:03
Ember Camp travel
App.Router.map ->
@resource 'filteredArticles', path: '/:filter'
App.FilteredArticlesRoute = Ember.Route.extend
model: (params) ->
blog = App.Blog.find(1) # get the user's Blog singleton
property = switch params.filter
when 'published' then 'publishedArticles'
when 'draft' then 'drafts'
when 'all' then 'articles'
diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js
index 76ceffe..1f45e96 100644
--- a/packages/ember-application/lib/system/application.js
+++ b/packages/ember-application/lib/system/application.js
@@ -446,9 +446,11 @@ var Application = Ember.Application = Ember.Namespace.extend(Ember.DeferredMixin
},
reset: function() {
- var oldContainer = get(this, '__container__');
- set(this, '__container__', null);
$ browserify <(echo "console.log('beep boop')") --deps | browser-pack | node
_stream_readable.js:704
throw new Error('Cannot switch to old mode now.');
^
Error: Cannot switch to old mode now.
at emitDataEvents (_stream_readable.js:704:11)
at Socket.Readable.resume (_stream_readable.js:689:3)
at Object.<anonymous> (/home/ubuntu/.npm-prefix/lib/node_modules/browser-pack/cmd.js:6:15)
at Module._compile (module.js:456:26)