Skip to content

Instantly share code, notes, and snippets.

View vsuharnikov's full-sized avatar

Vyatcheslav Suharnikov vsuharnikov

View GitHub Profile
@vsuharnikov
vsuharnikov / macos-assign-to-desktop-from-terminal.md
Created June 9, 2024 08:33 — forked from 0xdevalias/macos-assign-to-desktop-from-terminal.md
The following shows how you can tell macOS to assign an application to always show on all desktops, one specific desktop, or to unbind it.

macOS - Setting 'Assign to Desktop' via Terminal

The following shows how you can tell macOS to assign an application to show on one specific desktop, all desktops, or just a single desktop.

Show Current Config

⇒ defaults read com.apple.spaces app-bindings
@vsuharnikov
vsuharnikov / rocksdb_log_parser.py
Last active January 4, 2024 08:17
Parse LOG file tables of RocksDB
import numbers
import re
from datetime import datetime
import numpy as np
import pandas as pd
def convert_to_bytes(size_str):
@vsuharnikov
vsuharnikov / nixos-firefox-rebind-keys.nix
Last active January 6, 2023 07:10
How to rebind keys in Firefox in NixOS
{ pkgs, ... }: {
home-manager.users.youruser = {
programs.firefox = {
enable = true;
package = pkgs.firefox.override {
extraPrefs = ''
try {
let { classes: Cc, interfaces: Ci, manager: Cm } = Components;
const {Services} = Components.utils.import("resource://gre/modules/Services.jsm");
function ConfigJS() { Services.obs.addObserver(this, "chrome-document-global-created", false); }
@vsuharnikov
vsuharnikov / output.txt
Last active September 12, 2022 09:21
Convert an address in the Ethereum format to the Waves format
eth addr: 526938a6106aec0b2ec994e2288fcabcad54bfcb
waves addr: 3MwRqEZ4cBFRXShgNCyvKuVjcvLLtgWVvuZ
expected: 3MwRqEZ4cBFRXShgNCyvKuVjcvLLtgWVvuZ
@vsuharnikov
vsuharnikov / sway-focus-next.sh
Last active January 6, 2023 07:08
Focus next window in Sway
# ====================================================================================== #
# Focus the next window on the current workspace in sway, e.g. for binding to Alt+Tab #
# Depends: jq, sway #
# License: AS IS #
# Heavily inspired by i3 version https://gist.github.com/Nervengift/0ab9e6127ac17b8317ac #
# ====================================================================================== #
ws=$(swaymsg -t get_workspaces|jq "map(select(.focused))[]|.name")
windows=$(swaymsg -t get_tree|jq ".nodes|map(.nodes[])|map(select(.type==\"workspace\" and .name==$ws))[0]|[recurse(.nodes[])|select(.layout==\"none\")]|map({id: .id, focused: .focused})")
# https://stackoverflow.com/questions/53135035/jq-returning-null-as-string-if-the-json-is-empty
@vsuharnikov
vsuharnikov / predef.scala
Last active February 8, 2022 17:53
javap for Ammonite REPL
// ~/.ammonite/predef.sc
// Works on Scala 3, easy to adapt to Scala2
// Make sure:
// 1. You run Ammonite for Scala 3: 3.1-2.5.2+ (see https://github.com/com-lihaoyi/Ammonite/releases )
// 2. You provide required JVM exports:
// JAVA_OPTS="--add-exports=jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED" ~/Downloads/3.1-2.5.2
import java.io.{File, FileOutputStream}
import scala.util.Using
import scala.reflect.ClassTag
@vsuharnikov
vsuharnikov / vim_crash_course.md
Created December 29, 2021 08:43 — forked from dmsul/vim_crash_course.md
Vim Crash Course

NOTE: Specific examples given for options, flags, commands variations, etc., are not comprehensive.

NORMAL MODE

Vim has 2 main "modes", that chance the behavior of all your keys. The default mode of Vim is Normal Mode and is mostly used for moving the cursor and navigating the current file.

Some important (or longer) commands begin with ":" and you will see the text you enter next at the bottom left of the screen.

:q[uit] - quit (the current window of) Vim. ("Window" here is internal to Vim, not if you have multiple OS-level windows of Vim open at once.)
:q! - force quit (if the current buffer has been changed since the last save)
:e[dit] {filename} - read file {filename} into a new buffer.

@vsuharnikov
vsuharnikov / Main.scala
Created April 7, 2019 08:24
cats - foldLeftM - short circuit
val xs: List[Int] = List(1, 1, 2, 1, 1)
val result = xs.foldLeftM(0) {
case (r, x) =>
println(s"r=$r, x=$x")
if (x % 2 == 0) Left("even")
else Right(r + x)
}
println(result)
/*
@vsuharnikov
vsuharnikov / README.md
Created April 4, 2018 20:46
Удалям данные в ВК

Удаляем посты на стене

$$('.ui_actions_menu_item')
  .filter(function (x) {
    var attr = x.getAttributeNode('onclick');
    if (attr == null) return false;
    return attr.value.indexOf('delete') > 0;
  })
 .forEach(function (x) {
@vsuharnikov
vsuharnikov / logback.xml
Created December 28, 2017 14:54
Size and time rolled logs
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<property name="default.pattern" value="%date{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%.15thread] %logger{26} - %msg%n"/>
<property name="logback.file.final-directory" value="${logback.file.directory:-${waves.directory}/log}"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<target>System.out</target>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">