Skip to content

Instantly share code, notes, and snippets.

@nerevar
nerevar / Yin-Yang.php
Created March 7, 2012 11:11
Draws Yin-Yang in ASCII-mode
<?php
/*
Draws Yin-Yang in ASCII-mode
Usage: "php yin.php <size>"
Size must be greater then 10
Author Roman Rybalchenko mail@nerevar.ru
http://dumpz.org/84832/
13.09.2011
@nerevar
nerevar / clear screen
Created July 15, 2012 20:00
Draws a colored horizontal line and clear screen of terminal
# рисует горизонтальную линию и очищает экран
c()
{
SEPARATOR="-"
WIDTH=$(tput cols);
echo -e "\033[$(($RANDOM % 7 + 31))m"
for ((i=0; i<$WIDTH; i++)); do echo -n $SEPARATOR ; done
clear
}
@nerevar
nerevar / deps.js
Created January 7, 2014 18:38 — forked from narqo/deps.js
// Полная запись deps-сущности
{
block : 'bBlock',
elem : 'elem',
mod : 'modName',
val : 'modValue',
tech : 'techName', // технология, для которой собираются зависимости (например, js)
mustDeps : [], // подключатся до блока
shouldDeps : [], // порядок подключения не важен (важно лишь подключить)
@nerevar
nerevar / gulp-gitter.js
Last active August 29, 2015 13:57
С GNUMakefile на Gulp
var shell = require('shelljs');
module.exports = {
clone: function(repo, path, state) {
shell.exec('mkdir -p ' + path);
shell.exec('cd ' + path);
shell.exec('git init .');
shell.exec('git config remote.origin.url "' + repo + '"');
shell.exec('git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"');
@nerevar
nerevar / lectures.md
Last active June 4, 2016 12:45
yandex public video lectures

Про БЭМ:

Прикладное, про разработку:

@nerevar
nerevar / jsdoc-parser.js
Created January 7, 2016 20:37
Добавить шапочку jsdoc в файлы для определённых паттернов (функций вызовов счётчиков)
var fs = require('fs'),
_ = require('lodash'),
glob = require('glob'),
esprima = require('esprima'),
walk = require('esprima-walk'),
omitDeep = require('omit-deep');
var counterStrings = [
'w',
'c.hit',
it.only('должен вызывать _onSuccess при заданных параметрах', function(done) {
// TODO: 2. sinon ajax request
block = BEM.create('i-request_type_bem', { url: '/qwer' });
sinon.stub(block, '_getArgs').returns({});
sinon.stub(block, '_onSuccess', function(a, b, c, d) {
console.log('success', a,b,c,d);
done();
});
@nerevar
nerevar / boxplot.py
Last active June 4, 2016 09:08
python neat boxplot #python #matplotlib #boxplot #graph
import matplotlib.pyplot as plt
def draw(data):
bp = plt.boxplot(data,
widths=0.7,
notch=True, # adds median notch
patch_artist=True,
)
plt.grid(axis='y', # set y-axis grid lines
@nerevar
nerevar / grammar.pegjs
Created July 22, 2016 14:25
PEG.js filters grammar
/*
* PEG.js грамматика парсера фильтра результатов сравнения метрик
* Как обновлять грамматику:
* 1. Скопипастить исходник в http://pegjs.org/online
* 2. Указать Parser variable: window.filter_parser
* 3. Download parser
* 4. Минифицировать скачанный js код через: http://jscompress.com
* 5. Обновить файл filter_parser.pegjs.min.js
* 6. Запустить js unit-тесты: mocha filter_parser.pegjs.test.js
* 7. Обновить исходник в этом файле filter_parser.pegjs
@nerevar
nerevar / render_json.py
Last active February 26, 2023 04:31
Pretty print json in jupyter/ipython notebook
import json
import uuid
from IPython.display import display_javascript, display_html, display
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict) or isinstance(json_data, list):
self.json_str = json.dumps(json_data)
else:
self.json_str = json_data