Skip to content

Instantly share code, notes, and snippets.

View kavitshah8's full-sized avatar

Kavit Shah kavitshah8

  • Adobe
  • Bay Area, CA
View GitHub Profile
@kavitshah8
kavitshah8 / gist:9936360
Last active August 29, 2015 13:58
Different shell logins in Linux
http://rvm.io/support/faq#what-shell-login-means-bash-l
@kavitshah8
kavitshah8 / gist:10557889
Created April 12, 2014 21:30
JS: EmberUnitTest
//= require helper
describe( 'Object You Are Testing?', function () {
var test;
beforeEach(function () {
initApp();
} );
afterEach(function () {
it( 'sets venue property of a controller & resets it', function(){
var controller = lookup( 'controller', 'network_services.new' );
controller.set( 'model', Ember.Object.create() );
var mockController = sinon.mock( controller );
route.set( 'controller', controller );
mock.expects( 'modelFor' ).withArgs( 'venue' ).returns( venue );
@kavitshah8
kavitshah8 / homework.js
Last active August 29, 2015 14:00
I reorganized the node object as an object containing objects. I used particular format because property names are strings, they not sequential integers.
/*
A ---- B ----- C
| |
| |
D ------ E ------ F
*/
var node = {
"A" : {"id": 1, "value": 100, "neighbours": ["D","B"]},
"B" : {"id": 2, "value": 20, "neighbours": ["A","E","C"]},
@kavitshah8
kavitshah8 / homework.js
Last active August 29, 2015 14:00
Adds a color attribute to the objects to implement breadth first search algorithm.
/* A ---- B ----- C
| |
| |
D ------ E ------ F */
var allNodes = {
A : { "color": "WHITE" , "value": 20, "neighbours": ["D","B"] },
B : { "color": "WHITE" , "value": 10, "neighbours": ["A","E","C"] },
C : { "color": "WHITE" , "value": 30, "neighbours": ["B"] },
D : { "color": "WHITE" , "value": 20, "neighbours": ["A","E"] },
@kavitshah8
kavitshah8 / app.js
Last active August 29, 2015 14:00
Implements Depth First Search Algorithm to avoid modifying global variables.
var graph = {
A : { "value": 20, "neighbours": ["D","B"] },
B : { "value": 10, "neighbours": ["A","E","C"] },
C : { "value": 30, "neighbours": ["B"] },
D : { "value": 20, "neighbours": ["A","E"] },
E : { "value": 90, "neighbours": ["D","B","F"] },
F : { "value": 100, "neighbours": ["E"] }
};
@kavitshah8
kavitshah8 / shell-output
Created July 17, 2014 22:20
Extremely slow rebuilds
kavit:policy$ ember build
version: 0.0.39
Built project successfully. Stored in "dist/".
kavit:policy$ ember s
version: 0.0.39
Livereload server on port 35729
Serving on http://0.0.0.0:4200
Build successful - 4537ms.

Components are taking center stage in Ember 2.0. Here are some things you can do today to make the transition as smooth as possible:

  • In general, replace views + controllers with components
  • Only use controllers at the route level, and use Ember.Controller instead of Ember.ArrayController or Ember.ObjectController
    • Stay away from things like ItemControllers and calls to render(). Use components instead.
  • Don't use views
  • Use Ember CLI
  • Write your app in the "data down, actions up" paradigm
    • Not enforced, but you can still structure your app this way
    • Stay away from two-way bindings and mutability
@kavitshah8
kavitshah8 / unknownProperty.js
Last active August 29, 2015 14:14
InvalidArgument (possibly)
var Bar = Ember.Object.extend({
unknownProperty: function(p) {
// unknownProperty: function(key) {
console.log("Bar tried: "+key);
}
});
@kavitshah8
kavitshah8 / README.md
Created February 3, 2015 16:34
Ember-CLI Essentials:
  1. ember new ; ember build; ember s
  2. Install necessary libraries using ember-cli addon. For example, bootstrap, ic-ajax
  3. Include installed libraries in the Brocfile.js. Note: You need to include libraries which are installed using bower not npm.
  4. Make sure you can talk to server.