Skip to content

Instantly share code, notes, and snippets.

View karataev's full-sized avatar
:octocat:
¯\_(ツ)_/¯

Eugene Karataev karataev

:octocat:
¯\_(ツ)_/¯
View GitHub Profile
// Уже сегодня можно активно использовать Gulp 4
// Установка через npm:
npm install gulpjs/gulp#4.0
//Скорей всего глобально установлен gulp 3.x, но это не беда, gulp4 можно запускать и через npm. Для этого в package.json прописываем:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "./node_modules/.bin/gulp"
},
@karataev
karataev / app.js
Created February 7, 2016 07:48
Add/remove items by using directives with isolated scopes and a service
angular.module('app', [])
.controller('AppCtrl', ['Items', function (Items) {
var vm = this;
vm.items = Items.getAll();
vm.addNewItem = function () {
Items.addNewItem();
@karataev
karataev / app.js
Created February 7, 2016 16:17
Promises one by one VS bundle
angular.module('app', [])
.controller('AppCtrl', ['ChuckQuotes', function (ChuckQuotes) {
var vm = this;
vm.jokesToFetch = ChuckQuotes.amount;
vm.changeAmount = function (value) {
ChuckQuotes.amount = vm.jokesToFetch;
// Пример angular.component в Angular 1.5+
http://jsbin.com/musasenipe/edit?html,js,output
"use strict";
console.clear();
// Yor code here ...
function dscount(str, s1, s2) {
const pattern = `${s1}${s2}`;
const regexp = new RegExp(pattern, 'gi');
let matches;
let counter = 0;
while((matches = regexp.exec(str)) != null) {
@karataev
karataev / bitsDiff.js
Created December 1, 2017 18:11
Разница в количестве битов двух чисел
function leftPad(str, num) {
if (str.length >= num) return str;
var pad = new Array(num - str.length + 1).join('0');
return pad + str;
}
function bitsDiff(a, b) {
var aBin = a.toString(2);
var bBin = b.toString(2);
@karataev
karataev / facebook-post-parse.js
Created November 20, 2018 08:52
Parse list of users from a post and save it to .csv file
// open a list of users who interact with a post by clicking a number below the post
// execute function below in the browser's console
// PROFIT
(function() {
let result = [];
document.querySelectorAll('#reaction_profile_browser > li > div > div > div > div > div > div > a').forEach(item => result.push(item.textContent));
let csvContent = "data:text/csv;charset=utf-8,";
csvContent += result.join('\r\n');
let encodedUri = encodeURI(csvContent);
@karataev
karataev / events.css
Created November 29, 2018 14:20
Events capture/bubble visualization
div {
position: relative;
padding: 30px;
}
label {
display: block;
}
div:after {
@karataev
karataev / github-activity.js
Created August 8, 2019 12:48
Draw images on github's profile contribution graph with right mouse clicks
// execute this script in the github's page console
let colors = ['#196127', '#239a3b', '#7bc96f', '#c6e48b'];
function getRandomColor() {
let index = Math.floor(Math.random() * colors.length);
return colors[index];
}
document.addEventListener('contextmenu', e => {
e.preventDefault();
e.target.setAttribute('fill', getRandomColor())
@karataev
karataev / README.md
Created September 23, 2019 11:47
node-gyp on windows

Installing npm packages on windows might be a tough task. One project I worked on had these dependencies: "canvas": "1.6.13", "chartjs-node": "^1.7.1",

Installing these dependencies failed with error gyp ERR! build error

I googled this issue and there are a lot of pages regarding this. One of them: https://spin.atomicobject.com/2019/03/27/node-gyp-windows/