Skip to content

Instantly share code, notes, and snippets.

View 3AHAT0P's full-sized avatar
:octocat:

3@H@T0P 3AHAT0P

:octocat:
View GitHub Profile
import Ember from 'ember';
export default Ember.Component.extend({
isVisible: true
});
@3AHAT0P
3AHAT0P / components.test-one.js
Last active December 10, 2016 16:01
Ember 2.10.0 - Bug with inline styles
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: 'style'.w(),
style: '',
init() {
this._super(...arguments);
Ember.run.later(this, () => {
this.set('isVisible', true);
@3AHAT0P
3AHAT0P / components.test-one.js
Last active December 10, 2016 15:30
Ember 2.10.0 #14704 workaround
import Ember from 'ember';
const {
String: { htmlSafe }
} = Ember;
export default Ember.Component.extend({
attributeBindings: 'style'.w(),
style: '',
@3AHAT0P
3AHAT0P / components.test-one.js
Created December 10, 2016 16:01 — forked from workmanw/components.test-one.js
Ember 2.10.0 - Bug with inline styles
import Ember from 'ember';
export default Ember.Component.extend({
attributeBindings: 'style'.w(),
init() {
this._super(...arguments);
Ember.run.later(this, () => {
this.set('isVisible', true);
}, 5000);
import Ember from 'ember';
export default Ember.Component.extend({
componentName: 'rd-block',
mods: null,
classNameBindings: ['componentName', 'modClassNames'],
modClassNames: Ember.computed('componentName', 'mods', 'mods.[]', {
get() {
let componentName = this.get('componentName');
let mods = this.get('mods') || [];
(async () => {
const relation = (ModelClass, deserialize, serialize) => {
return (target, key, descriptor) => {
const proto = Reflect.getPrototypeOf(target);
if (!target.hasOwnProperty(Symbol.for('#meta'))) {
if (proto.hasOwnProperty(Symbol.for('#meta'))) {
Reflect.defineProperty(target, Symbol.for('#meta'), {value: {...proto[Symbol.for('#meta')]}});
} else {
Reflect.defineProperty(target, Symbol.for('#meta'), {value: {}});
}
@3AHAT0P
3AHAT0P / index.js
Last active April 12, 2019 10:57
Reverse string in JS
const isSupportSymbol = (symbolCode) => symbolCode === 55356 || (symbolCode >= 768 && symbolCode <= 879);
const reverse = (str) => {
let res = '';
let prevSymbol = null;
for (const symbol of str) {
if (isSupportSymbol(symbol.charCodeAt())) {
res = `${prevSymbol}${symbol}${res}`;
prevSymbol = null;
} else if (prevSymbol == null) {
prevSymbol = symbol;
@3AHAT0P
3AHAT0P / iterable-hash.ts
Created June 4, 2020 07:30
It's Hash with low cost iterations
class IterableHash<G extends string | number, T> {
[key: string]: T;
[key: number]: T;
// @ts-ignore
private primaryKeyIndex: G[] = [];
// @ts-ignore
private data: Record<G, T | void> = {};
// @ts-ignore
@3AHAT0P
3AHAT0P / ChunkerTransformStream.js
Created August 19, 2020 13:25
I created a NodeJS Transform Stream which repack data chunks to necessary size chunks
const { Transform } = require('stream');
const sliceBySize = (buffer, size, callback) => {
let chunk = buffer.slice(0, size);
let index = size;
while (chunk.length >= size) {
callback(chunk);
chunk = buffer.slice(index, index + size);
index += size;
@3AHAT0P
3AHAT0P / Matcher.ts
Last active June 10, 2021 11:43
My implementation matcher pattern (switch/case or some sequence if/else analogue)
export type Listener<TContext> = (context: TContext) => Promise<void> | void;
export type MatcherFn<TEvent extends string> = (event: TEvent) => TEvent | null;
export class Matcher<
TEvent extends string, TAdditionalEvent extends string = 'DEFAULT', TContext = any,
> {
private _listeners: Map<TEvent | TAdditionalEvent, Listener<TContext>[]> = new Map();
private _customMatchers: MatcherFn<TEvent | TAdditionalEvent>[] = [];