Skip to content

Instantly share code, notes, and snippets.

View victor-homyakov's full-sized avatar

Victor Homyakov victor-homyakov

View GitHub Profile
ajax: function(url) {
var req = this.createXMLHTTPObject();
if (req) {
try {
req.open('GET', url, false);
req.send('');
return req.responseText;
} catch (e) {
}
}
transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function (e) {
if (this.transitioning) {
if (e.type == 'show') this.reset()
this.transitioning = 0
this.$element.trigger(completeEvent)
}
}
// name: Remove To Do Planned and Done from column headings
// placeholder: restui_board
tau.mashups
.addDependency('tau/core/bus.reg')
.addModule('BusListeners', function(reg){
function Listener(bus, event, func){
this.bus = bus
this.event = event
@victor-homyakov
victor-homyakov / find-big-files-not-in-head.rb
Created February 20, 2015 09:24
Find big files in git history that don't exist in head. Usage: `ruby find-big-files-not-in-head.rb [size in MB] [rev]`
#!/usr/bin/env ruby -w
treshold, head = ARGV
head ||= 'HEAD'
Megabyte = 1000 ** 2
treshold = (treshold || 0.1).to_f * Megabyte
big_files = {}
commit_number = 0
commits_count = 0
@victor-homyakov
victor-homyakov / GitHub code review helper.js
Last active November 8, 2018 16:50
GitHub code review helper
// ==UserScript==
// @name GitHub code review helper
// @namespace https://github.com/victor-homyakov/
// @version 0.6.0
// @description Open/hide GitHub diff when clicking on diff header. Open/hide all diffs with the same extension when ctrl-clicking on diff file name.
// @author Victor Homyakov
// @copyright 2013+, Victor Homyakov
// @include https://github.com/*/*/commit/*
// @include https://github.com/*/*/pull/*
// @include https://github.com/*/*/compare/*
@victor-homyakov
victor-homyakov / detect-unused-css-selectors.js
Last active February 17, 2023 18:36
Detect unused CSS selectors. Show possible CSS duplicates. Monitor realtime CSS usage.
/* eslint-disable no-var,no-console */
// detect unused CSS selectors
(function() {
var parsedRules = parseCssRules();
console.log('Parsed CSS rules:', parsedRules);
detectDuplicateSelectors(parsedRules);
var selectorsToTrack = getSelectorsToTrack(parsedRules);
window.selectorStats = { unused: [], added: [], removed: [] };
console.log('Tracking style usage (inspect window.selectorStats for details)...');
/*
Setup:
npm i benchmark
npm i string-hash
Results on Node 8.6.0:
md5-hex x 411,933 ops/sec ±0.94% (84 runs sampled)
md5-base64 x 409,007 ops/sec ±2.13% (82 runs sampled)
sha1-hex x 426,509 ops/sec ±2.62% (83 runs sampled)
sha1-base64 x 426,735 ops/sec ±3.52% (80 runs sampled)
@victor-homyakov
victor-homyakov / links - burden of time.md
Last active July 20, 2019 11:41
Ссылки для презентации "Тяжёлое бремя времени"
@victor-homyakov
victor-homyakov / codemap.js
Last active November 22, 2019 11:10
Unit test to demonstrate 64-bit address processing error
/*global describe, it, CodeMap*/
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const vm = require('vm');
function load(file) {
const filename = path.join(__dirname, file);
const code = fs.readFileSync(filename).toString();
new vm.Script(code, { filename, displayErrors: true }).runInThisContext();
@victor-homyakov
victor-homyakov / links - performance metrics.md
Last active December 17, 2019 21:21
Ссылки для презентации "Производительность JS: чтобы улучшить,
 надо измерить"