Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working from home

Alex Kanunnikov lifeart

:octocat:
Working from home
View GitHub Profile
View components.my-component-two\.js
import Component from '@glimmer/component';
export default class extends Component {
get items() {
return this.args.foo.length;
}
}
@lifeart
lifeart / example.ts
Last active Mar 12, 2021
ember template imports
View example.ts
import Component from "@glimmer/component";
import { helper } from "@ember/component/helper";
import { setComponentTemplate } from "@ember/component";
import { hbs as tpl } from "ember-cli-htmlbars";
function asHelper(a, b, c) {
return {
value: helper(function (positional) {
return c.value.call(a, ...positional);
})
View controllers.application\.js
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { schedule } from '@ember/runloop';
export default class ApplicationController extends Controller {
queryParams = ['inputValue'];
@tracked _inputValue = '';
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Input with handler example';
@tracked text;
handleInput(event) {
event.preventDefault();
View controllers.application\.js
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Input with handler example';
@tracked text;
handleInput(event) {
event.preventDefault();
View controllers.application\.js
import Controller from '@ember/controller';
import { action } from '@ember/object';
export default class ApplicationController extends Controller {
@action sayHello() {
alert('Hello');
}
}
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
View controllers.application\.js
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class ApplicationController extends Controller {
@service('store') store;
constructor() {
super(...arguments);
const initial = this.store.createRecord('immutablel', { props: { name: 'Jake' }});
@lifeart
lifeart / index.js
Last active Jan 29, 2021
stateofjs mining
View index.js
const fs = require('fs');
const items = JSON.parse(fs.readFileSync('state_of_js_2016_2020.json', 'utf8'));
const last = items.filter((item) => [2020].includes(item.year));
// 2_5, 5_10, 10_20
const exp = last.filter((item) => ['1_2', '2_5', '5_10', '10_20'].map(e=>`range_${e}`).includes(item.user_info.years_of_experience));
// 10_30, 30_50, 50_100, 100_200,
const payd = exp.filter((item) => ['10_30','30_50', '50_100', '100_200'].map(e=>`range_${e}`).includes(item.user_info.yearly_salary));
const shape = {};
const fans = ['ember', 'react', 'angular', 'vuejs', 'other'];
@lifeart
lifeart / right-menu.js
Created Jan 27, 2021
right-menu-modifier
View right-menu.js
import { modifier } from 'ember-modifier';
// https://raw.githubusercontent.com/UnrealSecurity/context-js/main/context/context.js
function hasProp(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
const CONTEXT_CLASSES = {
ITEM: 'item',
CONTEXT: 'right-menu',