Skip to content

Instantly share code, notes, and snippets.

View vorou's full-sized avatar

Viktor Voropaev vorou

View GitHub Profile
// ==UserScript==
// @name Unnamed Script 703397
// @version 1
// @grant none
// @include https://github.com/*
// ==/UserScript==
window.addEventListener("DOMContentLoaded", function(event) {
document.querySelectorAll(".file-header").forEach(function(item) {
const copyLink = document.createElement('a');
"""
arr = [sorted ascending] -> [A|B] -> [B|A]
len(B) = len(arr) - len(A)
A could be empty (B is the whole array, pivot is at len(arr))
remember beacon = arr[0]
notice that it should be enough to figure out if we pass the pivot already for any val x in array
if we before pivot, than we need to go left for any number in range [beacon, x), otherwise go right
if we after pivot, we need to go right for any number in range (x, right], otherwise go left
"""
candidates
name
desc
img
vote_count
category_id
prev_rank
categories
id

IIS compression

  • use gzip (the default)
  • enable the IIS roles/Windows features: Web Server -> Performance -> Static/Dynamic
  • ensure the modules are listed in applicationHost.config:
<globalModules>
  <add name="DynamicCompressionModule" image="%windir%\System32\inetsrv\compdyn.dll" />
  <add name="StaticCompressionModule" image="%windir%\System32\inetsrv\compstat.dll" />
</globalModules>
#!/bin/bash
fd -0 -e mp3 | xargs -0 -I _ mv _ ./
fd -0 -e flac | xargs -0 -I _ mv _ ./
rm -r */
@vorou
vorou / expand_stacktraces.js
Created February 23, 2019 10:05
Adds "Expand all stacktraces" button to TeamCity build results page
// ==UserScript==
// @name add stacktraces expanding button
// @version 1
// @grant none
// ==/UserScript==
const button = '<a class="btn btn_mini btn_icon" href="#" title="Expand All" onclick="'+"document.querySelectorAll('.testWithDetails').forEach((el)=>el.click())"+'"><span>Expand stacktraces</span></a>';
const groupBySection = document.querySelector('.group-by-section');
groupBySection.parentNode.insertAdjacentHTML('beforeend', button);
https://stackoverflow.com/questions/7359702/how-do-i-obtain-a-query-execution-plan
http://www.sommarskog.se/query-plan-mysteries.html

using https://github.com/chardet/chardet to detect non-utf8 files

ls -re -file -inc *.cs,*.aspx,*.ascx,*.cshtml,*.js | ?{$_ -notmatch "node_modules"} | %{chardetect $_} | ?{$_ -match "1251"} | %{($_ -split ": ")[0]} | %{$x = cat $_; $x | set-content -encoding utf8 $_ }

using ag to count all occurences of a line

$n = 0; ag -c --cs Assert\. | %{$n += $_.split(":")[1]}; $n

using rust fd to find all C# projects where a lib is referenced, but not installed w/ NuGet

@vorou
vorou / hg.md
Last active August 8, 2018 08:22

all ancestors of a revision that are not ancestor of another revision

hg log -r "::a and not ::b"

specific branch

hg log -r "branch(foo)"

all active branches which not yet merged into battle

@vorou
vorou / tc-search-for-test-in-elk.js
Last active May 31, 2018 12:46
Add link to ELK search results in TeamCity
// ==UserScript==
// @name Add link to ELK search results
// @version 1
// @grant none
// @include http://tc-elba/*
// ==/UserScript==
console.log('wat');
function eventHandler() {