Skip to content

Instantly share code, notes, and snippets.

@gro-ove
gro-ove / audio_meter_monitor.cpp
Last active Dec 29, 2020
Easy way to get peak level of currently playing audio.
View audio_meter_monitor.cpp
#include <memory>
#include <string>
#include <iostream>
#include <Windows.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#pragma comment(lib, "Ole32.lib")
#define CRUCIAL(cmd) \
@gro-ove
gro-ove / yandex-market-check.js
Created Nov 9, 2020
Если запустить на странице с отзывами на товар на Яндекс.Маркете, соберёт остальные отзывы комментаторов и поищет интересные совпадения, когда разные люди оставляют одинаковые оценки на одинаковые товары или магазины.
View yandex-market-check.js
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();
View ConverterHelper.cs
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) {
View Switch.cs
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 / WrappedNodeJs.bat
Last active Aug 14, 2016
Wrapping zsh- or js-script inside a bat-file (for drag'n'drops)
View WrappedNodeJs.bat
// 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 Aug 9, 2016
Valve Data File parser and serializer, licensed under MS-PL.
View Vdf.cs
/// <summary>
/// VDF section.
/// </summary>
public class Vdf {
/// <summary>
/// String values.
/// </summary>
public Dictionary<string, string> Values { get; } = new Dictionary<string, string>();
/// <summary>
View AlignableWrapPanel.cs
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));
}