Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Yuriy Panarin PxyUp

🎯
Focusing
Block or report user

Report or block PxyUp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PxyUp
PxyUp / if.ts
Last active Apr 26, 2019
fasterDom If
View if.ts
import { createComponent, Component, rValue, bootstrap} from 'revact';
class Comp extends Component {
reactive = {
show: rValue(true),
text: rValue("Here timer")
}
get show() {
return this.reactive.show;
View react.jsx
render() {
const cond = true;
return {
<div>
{ cond ? <Component/> : (null) }
</div>
}
}
View router.ts
import { bootstrap, Component, rValue, createComponent, createRouter, Router, rList } from 'revact';
class Counter extends Component {
reactive = {
counter: rValue(0)
}
template = {
tag: "span",
textValue: this.reactive.counter,
@PxyUp
PxyUp / counterComponent.ts
Last active Apr 26, 2019
CounterComponent
View counterComponent.ts
import { bootstrap, Component, rValue, createComponent } from 'revact';
class Counter extends Component {
reactive = {
counter: rValue(0)
}
template = {
tag: "span",
textValue: this.reactive.counter,
@PxyUp
PxyUp / counter.ts
Last active Apr 26, 2019
FasterDom Counter
View counter.ts
import { bootstrap, rValue } from 'revact';
bootstrap('#app', () => {
const counter = rValue(0)
return {
tag: "div",
textValue: counter,
listeners: {
click: () => {
counter.value +=1
@PxyUp
PxyUp / HelloWorldFastDom.ts
Last active Apr 26, 2019
Hello World on Faster-Dom
View HelloWorldFastDom.ts
import { bootstrap } from 'revact';
bootstrap('#app', () => ({
tag: "div",
textValue: "Hello World!",
}))
@PxyUp
PxyUp / Golang2.md
Created Feb 19, 2019
Proposal of catch error
View Golang2.md

I like proposal with:

  • #name - invoke a handler by name
  • catch name {...} - define a handler

It solved many situations, but i think can be improved with panic and return state, like in proposal:

func returnError() error {
    return errors.New()
View index.js
let getResult = () => {
const hashMap = {}
document.querySelectorAll(".list-group-contest-item").forEach((item) => {
const auth = item.querySelector(".has-candidate .contest-item-candidate > a");
if (auth) {
const url = auth.href
hashMap[auth.textContent] = hashMap[auth.textContent] ? [hashMap[auth.textContent][0], hashMap[auth.textContent][1] + 1] : [auth.textContent, 1]
}
});
return Object.keys(hashMap).map((e) => hashMap[e]).sort((e, e2) => e2[1] - e[1])
@PxyUp
PxyUp / input.table.ts
Last active Oct 25, 2018
input.table.ts
View input.table.ts
@Input() itemSize = 25; // for itemHeight
@Input() dataSource: Observable<Array<VirtualTableItem | number | string | boolean>>;
@Input() filterPlaceholder = 'Filter';
@Input() dataSetEmptyPlaceholder = 'Data is empty';
@Input() config: VirtualTableConfig;
@PxyUp
PxyUp / virtual.table.config.ts
Last active Oct 26, 2018
virtual.table.config.ts
View virtual.table.config.ts
export interface VirtualTableConfig {
column?: Array<VirtualTableColumn>; // if config not provide will be auto generate column
filter?: boolean; // default false
header?: boolean; // default true
}
export interface VirtualTableColumn {
name?: string; // Label for field, if absent will be use key
key: string; // Uniq key for filed,
func?: (item: VirtualTableItem) => any; // function for get value from dataSource item
comp?: (a: any, b: any) => number; // function for compare two item, depend from `func` function
You can’t perform that action at this time.