Skip to content

Instantly share code, notes, and snippets.

@PxyUp
PxyUp / cloudSettings
Last active September 4, 2018 08:41 — forked from gund/bd3d4befe38185704bf0fc875e9deed6\configuration.json
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-09-04T08:41:41.171Z","extensionVersion":"v3.1.2"}
@PxyUp
PxyUp / virtual.table.config.ts
Last active October 26, 2018 09:45
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
@PxyUp
PxyUp / input.table.ts
Last active October 25, 2018 16:17
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 / index.js
Created February 5, 2019 15:19
GetResults
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 / Golang2.md
Created February 19, 2019 21:55
Proposal of catch error

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()
@PxyUp
PxyUp / HelloWorldFastDom.ts
Last active April 26, 2019 22:17
Hello World on Faster-Dom
import { bootstrap } from 'revact';
bootstrap('#app', () => ({
tag: "div",
textValue: "Hello World!",
}))
@PxyUp
PxyUp / counter.ts
Last active April 26, 2019 22:16
FasterDom Counter
import { bootstrap, rValue } from 'revact';
bootstrap('#app', () => {
const counter = rValue(0)
return {
tag: "div",
textValue: counter,
listeners: {
click: () => {
counter.value +=1
@PxyUp
PxyUp / counterComponent.ts
Last active April 26, 2019 22:16
CounterComponent
import { bootstrap, Component, rValue, createComponent } from 'revact';
class Counter extends Component {
reactive = {
counter: rValue(0)
}
template = {
tag: "span",
textValue: this.reactive.counter,
@PxyUp
PxyUp / router.ts
Last active April 26, 2019 22:16
Router
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 / react.jsx
Created April 14, 2019 18:40
react If
render() {
const cond = true;
return {
<div>
{ cond ? <Component/> : (null) }
</div>
}
}