Skip to content

Instantly share code, notes, and snippets.

View melikhov-dev's full-sized avatar

Andrey Melikhov melikhov-dev

View GitHub Profile
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Admin controller:
*
* @author
* @package
* @version
*/
class Controller_Admin_Statistic extends Controller_Admin_Abstract
@melikhov-dev
melikhov-dev / utils.js
Created November 17, 2016 11:30
пример
createCommand: function(name, runner) {
var commandTimeout = ref(settings, 'config.indexer.' + name + '.timeout');
return new Command({
name: name,
runner: runner,
url: baseAddress,
prepare: prepares.indexer,
ssl: sslOptions,
timeout: commandTimeout || backendTimeout,
// ES6 9.2.3.2 Function.prototype.bind(thisArg , ...args)
function FunctionBind(this_arg) { // Length is 1.
if (!IS_CALLABLE(this)) throw MakeTypeError(kFunctionBind);
var boundFunction = function () {
// Poison .arguments and .caller, but is otherwise not detectable.
"use strict";
// This function must not use any object literals (Object, Array, RegExp),
// since the literals-array is being used to store the bound data.
if (!IS_UNDEFINED(new.target)) {
return %NewObjectFromBound(boundFunction);
const http2 = require('http2');
const fs = require('fs');
const url = require('url');
const path = require('path');
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
const mimeType = {
'.ico': 'image/x-icon',
const server = http2.createSecureServer(options);
const commonCSS = fs.readFileSync('common.css');
server.on('stream', (stream, headers) => {
console.log(`${headers[':method']} ${headers[':path']}`);
const parsedUrl = url.parse(headers[':path']);
let pathname = `.${parsedUrl.pathname}`;
const ext = path.parse(pathname).ext;
if (headers[':path'] === '/index.html') {
stream.pushStream({ ':path': 'common.css' },
const cacheName = 'v1';
this.addEventListener('install', function(event) {
event.waitUntil(
caches.open(cacheName).then(function(cache) {
return cache.addAll([
'index.html',
'common.css'
].map(u => new Request(u, { credentials: 'include' })))
}).then(()=> console.log('done'))
);
// Определяем состояние и методы для его обновления
class MobxState {
@observable items = []
addItem (item) {
this.items.push(item)
}
}
// Компоненты
@observer
class Items extends Component {
// Определяем состояние и методы для его обновления
function ReduxState (state = Immutable.fromJS({items: []}), action) {
switch (actions.type) {
case 'addItem':
return state.push('items', action.item)
}
return state
}
// Компоненты
const Items = connect(
const controller = Controller({
state: {
items: []
},
signals: {
itemAdded: push(state`items`, props`item`)
}
})
// Компоненты
const Items = connect({
@observer
class Items extends Component {
render() {
return (
<div>
<ul>
{this.props.store.items.map((item) => <li>{item}</li>)}
</ul>
<button onClick={() => this.props.store.addItem('foo')}>
Add foo