Skip to content

Instantly share code, notes, and snippets.

View valerysntx's full-sized avatar
🔋
99%

valery sntx valerysntx

🔋
99%
  • Ukraine, Uzhgorod
View GitHub Profile
@valerysntx
valerysntx / websocket.py
Created October 27, 2017 15:40 — forked from julienguigner/websocket.py
Python 3.1 version of python-websocket
"""
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@valerysntx
valerysntx / mubpub.js
Created September 6, 2017 17:59
mubpub publish / subscribe using mongodb channels
var mubsub = require('mubsub');
const uuid = require('uuid');
let url = 'mongodb://bellawe.com:27017/renderProtocol';
var clientA = mubsub(url);
var clientB = mubsub(url);
var inbound = clientA.channel('inbound', {recreate: true });
var outbound = clientB.channel('outbound', {recreate: true });
@valerysntx
valerysntx / reactdemo.py
Created August 22, 2017 21:35
pythonic react
# Helper functions
def h(elm_type, props='', *args):
return React.createElement(elm_type, props, *args)
def render(react_element, destination_id, callback=lambda: None):
container = document.getElementById(destination_id)
ReactDOM.render(react_element, container, callback)
@valerysntx
valerysntx / render-server.sh
Created June 13, 2017 14:46
render-server.sh
sudo docker run -it -v /renders:/service/renderServer/RenderServer/renders valerysntx/render-server:ci bash -c 'NODE_ENV=production cd / && node /service/renderServer/RenderServer/client/app.js'
docker-machine create -d virtualbox --virtualbox-boot2docker-url https://github.com/StefanScherer/boot2docker/releases/download/v1.10.1-386/boot2docker.iso dev32
@valerysntx
valerysntx / simplemapper.cs
Created March 15, 2017 20:01
SimpleMapper.cs
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
@valerysntx
valerysntx / observable_{any}.ts
Last active December 31, 2016 17:43
Observable of any / no-generics
class Observer {
public action: (T) => any;
constructor(action: (T) => any) {
this.action = action;
}
public Set(value: any) {
@valerysntx
valerysntx / observable_T.ts
Last active December 31, 2016 17:02
Observable of <T>
interface IObserver<T> {
Notify(observer:Observer<T>, value:T)
}
class Observer<T> {
action: (T) => any;
public Set(value: (T) => T) {
this.action = value;
@valerysntx
valerysntx / MemoizeWithExpire.cs
Last active December 28, 2016 06:57
Cached Value Factory with Expiration
async static Task Main()
{
(await GetCachedContentAsync (new Uri ("http://foo"))).Dump();
//(await GetCachedContentAsync (new Uri ("http://foo"))).Dump();
}
static Task<string> GetContent (Uri uri) {
return Task.Delay (1000).ContinueWith (_ => "slow");
}
@valerysntx
valerysntx / windows-bash.docker.cli.sh
Created December 11, 2016 03:56
native docker client 1.12.2 on windows subsystem for linux
wget https://get.docker.com/builds/Linux/x86_64/docker-1.12.2.tgz
tar -xzvf docker-1.12.2.tgz
cd docker
env DOCKER_HOST=tcp://0.0.0.0:2375
mkdir ~/bin
mv docker ~/bin
cat "export DOCKER_HOST=tcp://0.0.0.0:2375" > ~/.bashrc
cat "export PATH=$PATH:~/bin" > ~/.bashrc