Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Julien Guimont juggy

🎯
Focusing
View GitHub Profile
View asset_helper.rb
module Core
module AssetHelper
def self.root_path
String === Rails.root ? Pathname.new(Rails.root) : Rails.root
end
def self.add_extension(filename, extension)
filename.to_s.split('.').include?(extension) ? filename : "#{filename}.#{extension}"
end
View components.my-component.js
import Ember from 'ember';
const Component = Ember.Component.extend({
layoutName: "components/my-component",
tagName: "form",
foo: null
});
Component.reopenClass({
positionalParams: ["foo"]
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
counter: Ember.computed({
get(){
return 0;
},
set(k,v){
@juggy
juggy / cloudSettings
Last active Jul 31, 2020
New Twiddle
View cloudSettings
{"lastUpload":"2020-07-31T15:59:44.337Z","extensionVersion":"v3.4.3"}
View gist:bab5bbc8c09f0655692518870f8d9c5e
ubuntu@ip-172-31-21-253:/var/deploy/vroom-staging/web_head/releases/20161004023037/front-end$ ./node_modules/.bin/ember build --environment="production"
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
⠋ BuildingTorii is installed but not configured in config/environment.js!
Build failed.
File: assets/vendor.js (123701:7)
The Broccoli Plugin: [UglifyWriter] failed with:
Error
at new JS_Parse_Error (<anonymous>:1545:18)
at js_error (<anonymous>:1553:11)
View gist:d9fd704bfee4cd41b8927b7bff2a8c0e
const fieldList = [
{ label: 'Foo Fields', fields: [{name: 'foo', selected: false}] },
{ label: 'Bar Fields', fields: [{name: 'bar', selected: true}] }
]
fields: Ember.computed('fieldList.@each.fields', function() {
return this.get("fieldList").mapBy("fields");
}),
enabledFields: Ember.computed("fields", "fields.@each.selected", function(){
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
building: Ember.computed(function(){
return {id: 1, name: "BUILDING!"}
})
});
View application.controller.js
import Ember from 'ember';
class ItemRating extends HTMLElement {
createdCallback () {
this.insertAdjacentHTML('afterbegin', `
<a data-rating="1">&#9733;</a>
<a data-rating="2">&#9733;</a>
<a data-rating="3">&#9733;</a>
<a data-rating="4">&#9733;</a>
<a data-rating="5">&#9733;</a>
View sortable-header.js
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'th',
downArrow: '&#9660;',
upArrow: '&#9650;',
actions: {
sortBy(model, sortProperty, order) {
// Remove all selected classes from all the header links
View gist:5abec1b9d110ff88b823
class Core::PaginationSerializer < ActiveModel::ArraySerializer
def initialize(object, options={})
meta_key = options[:meta_key] || :meta
options[meta_key] ||= {}
pobject = options[:pagination_object] || object
options[meta_key][:pagination] = {
current_page: pobject.current_page,
next_page: pobject.next_page,