Skip to content

Instantly share code, notes, and snippets.

Содержимое удалено по требованию правообладателя.
var userData = $jin.atom({ pull: function( ){
setTimeout( function( ){
userData.put({ name: 'User', time: Date.now() })
}, 1000 )
}})
userData
.then( function( val ){
@nin-jin
nin-jin / gist:13297c8723ecf4516dda
Last active August 29, 2015 14:04
Инкапсуляция и сокрытие
/**
* Инкапсуляция
*
* @class Greeter1
*/
var Greeter1 = function(){}
/**
* Генерирует прикольное имя
*
@nin-jin
nin-jin / gist:111f32935da5c758a1c8
Last active November 25, 2015 04:51
Dlang non blocking messaging
import std.stdio;
import std.concurrency;
import std.conv;
import core.thread;
shared class Msg
{
string value;
Msg next = null;
Tid from;
@nin-jin
nin-jin / coroutine.d
Last active October 9, 2015 14:59
Sorting comparison
import vibe.core.core;
import core.time;
import std.stdio;
int counter;
void say( string name ) {
for ( int i = 0 ; i < 3; i++ ) {
sleep( 100.msecs );
writeln( ++counter , " " , name );
import std.stdio;
T eval( string op , T )( T a , T b ) {
return mixin( q{a} ~ op ~ q{b} );
}
unittest {
writeln( eval!q{/}( 123 , 0 ) );
}
@nin-jin
nin-jin / args.js
Created May 2, 2017 10:50
NodeJS arguments processing
var args = {}
process.argv.slice(2).forEach( param => {
var values = param.split( '=' )
var key = values.shift()
args[ key ] = ( args[ key ] || [] ).concat( values.join( '=' ) )
} )
var actions = {
'help help' : args => `help\t\tPrints help (default action)\n` ,
'help' : args => `\nSuper-puper server!\n${ actions['actions']() }${ actions['options']() }`,
@nin-jin
nin-jin / harp-request.md
Last active December 1, 2021 12:53
HARP - Hypermedia Abstract Resource Protocol

Requirements:

  1. One line query through uri.
  2. Filtering
  3. Sorting
  4. Limitation
  5. Partial fetching
  6. Fetching linked resources
  7. Normalized response
  8. Bulk requests
@nin-jin
nin-jin / tests.ts
Last active March 13, 2020 10:51
Статикодинамические валидаторы
type TestUserType = Assert<
typeof User.Value,
{
readonly name: string
readonly birthday: Moment
readonly email: string & { Brand: "Email" } | undefined
}
>