Skip to content

Instantly share code, notes, and snippets.

@lahmatiy
lahmatiy / basis.net.Transport_requestHeaders_patch.js
Last active December 19, 2015 06:29
Returns extra request headers for basis.net.Transport that sending prior to 0.9.5
basis.require('basis.net');
basis.net.AjaxTransport.prototype.requestHeaders['X-Requested-With'] = 'XMLHttpRequest';
basis.net.AjaxTransport.prototype.requestHeaders['X-Powered-By'] = 'basis.js';
@lahmatiy
lahmatiy / basis.data.property.AbstractProperty_restore.js
Created June 30, 2013 18:06
Path to restore basis.data.property.AbstractProperty (dropped in 0.9.4)
basis.require('basis.data');
basis.require('basis.data.property');
basis.namespace('basis.data.property').extend({
AbstractProperty: basis.data.Value
});
@lahmatiy
lahmatiy / basis.data.Value#set_forceEvent.js
Last active December 19, 2015 04:18
Path to restore forceEvent argument and boolean result for basis.data.Value#set (dropped in 0.9.4)
basis.require('basis.data');
(function(){
var set_ = basis.data.Value.prototype.set;
basis.data.Value.prototype.set = function(value, forceEvent){
var valueBeforeSet = this.value;
set_.call(this, value);
@lahmatiy
lahmatiy / basis.data.Value#updateCount.js
Last active December 19, 2015 04:09
Patch to restore basis.data.Value#updateCount (dropped in 0.9.4)
basis.require('basis.data');
(function(){
var emit_change_ = basis.data.Value.prototype.emit_change;
basis.data.Value.extend({
updateCount: 0,
emit_change: function(){
this.updateCount += 1;
emit_change_.apply(this, arguments);
}
@lahmatiy
lahmatiy / basis_data_DataObject_restore.js
Created June 30, 2013 15:20
Patch to restore basis.data.DataObject alias for basis.data.Object (dropped in 0.9.4)
basis.require('basis.data');
basis.data.DataObject = basis.data.Object;
@lahmatiy
lahmatiy / basis_net_rpc_callback_patch.js
Created June 29, 2013 15:32
This patch bring back basis.net.rpc.callback which was droped in 0.9.4
basis.require('basis.data');
basis.require('basis.net.rpc');
basis.net.rpc.extend({
callback: {
setProcessing: function(){
this.setState(basis.data.STATE.PROCESSING);
},
setUndefined: function(){
this.setState(basis.data.STATE.UNDEFINED);
@lahmatiy
lahmatiy / basis_net_AbstractRequest_failure_on_abort_patch.js
Last active December 19, 2015 03:39
Patch that emit failure event before abort event for AbstractRequest. This behaviour was changed in 0.9.4
basis.require('basis.event');
basis.require('basis.data');
basis.require('basis.net');
basis.net.AbstractRequest.extend({
stateOnAbort: basis.data.STATE.ERROR,
emit_abort: function(){
this.emit_failure();
basis.event.events.abort.call(this);
}
@lahmatiy
lahmatiy / .bowerrc
Created June 1, 2013 13:40
Usually we store 2 files in project for bower: .bowerrc for settings & bower.json for description and dependencies. But we can use single file for both, just put everything into .bowerrc and set "json" property to ".bowerrc".
{
"json": ".bowerrc",
"directory": "lib",
"name": "my-project",
"version": "1.0.0",
"dependencies": {
"basisjs": "0.9.0"
}
}
@lahmatiy
lahmatiy / gist:5593176
Created May 16, 2013 16:46
Text that always in center and fit window size
<!doctype html>
<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" style="position: fixed; width: 100%; height: 100%">
<text x="0" y="81" fill="black" stroke="black" font-size="100">A!</text>
</svg>
</body>
</html>
@lahmatiy
lahmatiy / custom-progressbar.js
Last active August 29, 2015 14:26
Done on the knee progressbar
var chalk = require('chalk');
var readline = require('readline');
var BAR_LENGTH = 40;
var lines = 0;
function repeatStr(str, len){
return new Array(parseInt(len) + 1).join(str);
}
function drawBarLine(fill, str){