Skip to content

Instantly share code, notes, and snippets.

View narqo's full-sized avatar
☀️
Berlin, +18°

Vladimir Varankin narqo

☀️
Berlin, +18°
View GitHub Profile
@narqo
narqo / server.js
Last active December 21, 2015 22:29
Test for http request and the globals
var http = require('http'),
util = require('util'),
port = process.env.PORT || 3014,
counter = 1;
/* global lang:true */
lang = 'ru';
function onRequest(req, res) {
counter += 1; // Oops
@narqo
narqo / gist:5671575
Created May 29, 2013 16:19
How to redefine something in BEMHTML?
// PRJ/[...]/b-page.bemhtml
block b-page {
default: {
var ctx = this.ctx,
dtype = apply(this._mode = 'doctype'),
buf = [
dtype,
{
@narqo
narqo / test-promise.js
Last active December 17, 2015 09:29
Some tricks with Promise-A+
var args = { /* ... */ };
someActionThatRetrievesArchPromise()
.then(function(Arch) {
var arch = Arch.alterArch();
return arch
.invoke.call(Arch, 'createExamplesNodes', args)
.then(function() {
return arch;
});
@narqo
narqo / backtrace.js
Last active December 16, 2015 23:39
How to get file/method info in JavaScript code. For example for logging
/* jshint expr:true, boss:true, node:true */
var backtrace = new Error().stack.split('\n');
var i = 0, line, parts;
while(line = backtrace[i++]) {
if(line.indexOf(__dirname) === -1) {
continue;
}
@narqo
narqo / deps.js
Last active December 16, 2015 10:19
deps.js syntax
// Полная запись deps-сущности
{
block : 'bBlock',
elem : 'elem',
mod : 'modName',
val : 'modValue',
tech : 'techName', // технология, для которой собираются зависимости (например, js)
mustDeps : [], // подключатся до блока
shouldDeps : [], // порядок подключения не важен (важно лишь подключить)
@narqo
narqo / bbem
Created April 3, 2013 10:11
Workaround about local bem-tools installation
#!/usr/bin/env bash
npm_bem=`npm bin`/bem
home_bem=$HOME/bin/bem
global_bem=bem
bem_=$global_bem
if [ -f "$npm_bem" ]; then
bem_=$npm_bem
/**
* @fileOverview [Node.js zlib module](http://nodejs.org/docs/v0.8.22/api/zlib.html) tests
* with `'accept-encoding': 'gzip'` http request
*/
var http = require('http'),
zlib = require('zlib'),
rqopts = {
host : 'api.twitter.com',
@narqo
narqo / htttest.js
Created March 19, 2013 19:51
Тестовый обработчик POST-запроса в Node.js
› node htttest.js && curl -d "user=someone" --url http://127.0.0.1:4001
@narqo
narqo / gist:3898567
Created October 16, 2012 10:33
Задания для JS-стажера

Решения оформлять в виде репозитория на github.


Написать функцию, которая проверяет, является ли входящая строка палиндромом.


По какому-либо событию на странице выполняется определённое действие. Выполнять его чаще, чем n раз в секунду слишком «дорого».

@narqo
narqo / dabblet.css
Created February 11, 2012 23:50
Table row with border-radius and box-shadow playgroud
/**
* Table row with border-radius and box-shadow playgroud
*/
html{
min-height:100%;
}
body{
background-image:-o-linear-gradient(top, #fff, #dcdcdc);
background-image:-moz-linear-gradient(top, #fff, #dcdcdc);
background-image:-webkit-linear-gradient(top, #fff, #dcdcdc);