Skip to content

Instantly share code, notes, and snippets.

@gro-ove
gro-ove / yandex-market-check.js
Created November 9, 2020 09:39
Если запустить на странице с отзывами на товар на Яндекс.Маркете, соберёт остальные отзывы комментаторов и поищет интересные совпадения, когда разные люди оставляют одинаковые оценки на одинаковые товары или магазины.
javascript:(function () {
function wait(ms = null) {
return new Promise(r => setTimeout(r, ms == null ? (500 + Math.random() * 1e3) : ms));
}
async function clickWait(parent, query) {
const e = parent.querySelector(query);
if (!e) return false;
e.click();
await wait();
@gro-ove
gro-ove / audio_meter_monitor.cpp
Last active December 29, 2020 19:56
Easy way to get peak level of currently playing audio.
#include <memory>
#include <string>
#include <iostream>
#include <Windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#pragma comment(lib, "Ole32.lib")
#define CRUCIAL(cmd) \
public static class ConverterHelper {
public static int AsInt([CanBeNull] this object value) {
return value.AsInt(0);
}
public static int AsInt([CanBeNull] this string value) {
return value.AsInt(0);
}
public static int AsInt([CanBeNull] this object value, int defaultValue) {
public abstract class BaseSwitch : FrameworkElement {
public static readonly DependencyProperty ResetElementNameBindingsProperty = DependencyProperty.Register(nameof(ResetElementNameBindings), typeof(bool),
typeof(BaseSwitch), new FrameworkPropertyMetadata(false));
public bool ResetElementNameBindings {
get { return (bool)GetValue(ResetElementNameBindingsProperty); }
set { SetValue(ResetElementNameBindingsProperty, value); }
}
protected abstract UIElement GetChild();
@gro-ove
gro-ove / AlignableWrapPanel.cs
Created March 10, 2016 11:44
AlignableWrapPanel
public class AlignableWrapPanel : Panel {
public AlignableWrapPanel() {
_orientation = Orientation.Horizontal;
}
private static bool IsWidthHeightValid(object value) {
var v = (double)value;
return (double.IsNaN(v)) || (v >= 0.0d && !double.IsPositiveInfinity(v));
}
@gro-ove
gro-ove / WrappedNodeJs.bat
Last active August 14, 2016 12:34
Wrapping zsh- or js-script inside a bat-file (for drag'n'drops)
// 2>nul & node %0 "%1" "%2" "%3" "%4" "%5" & goto :eof
var fs = require('fs');
var readline = require('readline');
console.log('\u001BcNode.JS is here!');
console.log(` Working dir: ${__dirname}`);
console.log(` Arguments: ${process.argv.slice(2).join(' ')}`);
var rl = readline.createInterface({
@gro-ove
gro-ove / Vdf.cs
Created August 9, 2016 20:59
Valve Data File parser and serializer, licensed under MS-PL.
/// <summary>
/// VDF section.
/// </summary>
public class Vdf {
/// <summary>
/// String values.
/// </summary>
public Dictionary<string, string> Values { get; } = new Dictionary<string, string>();
/// <summary>