This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mix.Tasks.CreateSchemaFromRails do | |
use Mix.Task | |
defmodule EctoPrinter do | |
def build_string(module_name, %{name: table_name, body: body}) do | |
model_name = | |
table_name | |
|> String.trim_trailing("s") | |
|> Macro.camelize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a getter for the given css selector | |
* that will return a native element | |
* @param selector A css selector string | |
*/ | |
export function element(selector: string) { | |
return function(target: any, key: string) { | |
delete target[key]; | |
Object.defineProperty(target, key, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'A Really Simple Rolodex', | |
newEntry: null, | |
entries: Ember.computed.alias('model'), | |
showForm: false, | |
actions: { | |
addEntry() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from "ember"; | |
export default Ember.Component.extend({ | |
staticValue: Ember.computed("condition", "scenario", function() { | |
let key = this.get("condition"); | |
return this.get("scenario").get(key); | |
}), | |
init() { | |
this._super(...arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
To use this file you'll need to have `jscodeshift` (https://github.com/facebook/jscodeshift) | |
installed, which you can get through npm or yarn. | |
You can invoke it as follows: | |
`jscodeshift -t add-super-calls.js ~/path/to/js/files/` | |
You can pass `-d` to do a dry-run. | |
*/ | |
const hookNames = [ | |
'init', | |
'didInitAttrs', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
queryParams: ['foodId'], | |
foodId: null, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/accordion-item.js | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
item: null, | |
activeItem: null, | |
isExpanded: Ember.computed('activeItem', 'item', function() { | |
return this.get('activeItem') === this.get('item'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
item: null, | |
openItem: null, | |
isOpen: Ember.computed('item', 'openItem', function() { | |
return this.get('item') === this.get('openItem'); | |
}), | |
classNames: ['item'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/accordion-item.js | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
item: null, | |
activeItem: null, | |
isExpanded: Ember.computed('activeItem', 'item', function() { | |
return this.get('activeItem') === this.get('item'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// components/accordion-item.js | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'div', | |
item: null, // passed-in | |
isExpanded: Ember.computed('activeItem', 'item', function() { | |
return this.get('activeItem') === this.get('item'); | |
}) |
NewerOlder