Skip to content

Instantly share code, notes, and snippets.

View asci's full-sized avatar
🍊

Artem R asci

🍊
View GitHub Profile
@asci
asci / index.js
Last active September 10, 2015 07:34
Arrow functions problem
const test = 0;
let superLongValue = 'other value';
const someObject = {};
someObject.methodB = test >= superLongValue + 'text';
someObject.otherMethodC = test => superLongValue = test;
@asci
asci / index.spec.js
Last active August 29, 2015 14:27
angular $q is not working in test env
var inject = angular.mock.inject;
var $q;
describe('$q is really strange', function (){
beforeEach(inject(function ($injector){
$q = $injector.get('$q');
}));
it('should proof that q is working properly', function (done){
var lastRequest = $q.defer();
@asci
asci / sample.js
Created August 3, 2015 08:38
chainer
function toChain(target) {
var queue = [];
var lastReturn;
Object.keys(target).forEach(function (prop) {
var original;
if (typeof target[prop] === 'function') {
original = target[prop];
target[prop] = function () {
var args = arguments;
App.SomeIndexRoute = Ember.Route.extend({
model: function () {
return this.store.find('some');
}
});
App.SomeShowRoute = Ember.Route.extend({
model: function (params) {
console.log('========================reload=========================='); // не вызывается если кликнуть по ссылке /#/some/111, но вызывается если обновить страницу
var some = this.store.find('some', params.id);
function moduleFor(fullName, description, callbacks, delegate) {
var container;
var context;
var _callbacks = {
setup: function(){
callbacks = callbacks || { };
var needs = [fullName].concat(callbacks.needs || []);
container = isolatedContainer(needs);
#include <Arduino.h>
#include "Chassis.h"
#define STOP 0
#define FORWARD 1
#define RIGHT 2
#define LEFT 4
#define BACKWARD 5
Chassis::Chassis(int D1, int P1, int D2, int P2) {
var inst = {
name: 'custom name',
init: function () {
var _this = this;
$('body').on('click', function () {
_this.getName(); // переменная _this берется из замыкания
});
},
getName: function () {
console.log(this.name);
// Block
BN
.decl('main-page', 'mod', 'val') // mod and val are optional, but maybe we should prohibit modifications for javascript and use it only as CSS\DOM states
.deps('page', 'content') // Maybe depricated
.extends('page', 't-block') // Multiple inheritance: for data and view - complicate, for methods - override
// Initial code, e.g. for pages router - runs after block been declarated. alt names - 'runs', 'runAfterDecl'
.init(function () {
@asci
asci / contactsapp.js
Created October 18, 2013 21:23
JSON Driven Development
var app = {
name: 'Contact list',
version: '0.1',
db: 'mysql',
transports: ['http', 'websocket'],
auth: {
controllers: 'Contact',
types: {
vk: {
appCode: 1231341,
@asci
asci / gist:5609188
Last active December 17, 2015 12:19
var Validator = (function (){
var rules = [];
return {
_add: function (rule) {
if (rules[rule.objectName] === undefined) {
rules[rule.objectName] = [];
}
rules[rule.objectName].push(rule);
},
configurate: function (rules) {