Skip to content

Instantly share code, notes, and snippets.

View stanislavvv's full-sized avatar

Stanislav Vlasov stanislavvv

  • Yekaterinburg
View GitHub Profile
@stanislavvv
stanislavvv / xorg.conf
Created August 18, 2023 07:28
Two monitors, two videocards, one screen (after randr configuration)
# Discrete Card as Primary GPU, internal Intel Card as Secondary
Section "ServerLayout"
Identifier "layout"
Screen 0 "nouveau"
Inactive "intel" # use *randr for config after login
EndSection
Section "Device"
Identifier "nouveau"
@stanislavvv
stanislavvv / thermald.sh
Created May 10, 2022 13:26
thermald replacement for arm singleboard
#!/bin/bash
# get temperature and on thresholds change system frequencies to lower or higher
# tested only on Orange Pi 3 LTS
TEMPPATH="/sys/devices/virtual/thermal/thermal_zone*"
TEMPFILENAME="temp"
TEMP_MAX=84000
TEMP_MIN=77000
@stanislavvv
stanislavvv / script-template.sh
Created January 20, 2022 15:14 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@stanislavvv
stanislavvv / sqrt.c
Created September 11, 2020 19:46
integer square root by Newton method
// (C) https://habr.com/ru/post/515018/#comment_21971060
//Возвращаемый результат - 32 бита, т.к. для
//больших входных чисел вроде 65536*65536-1,-2,...
//с учетом максимальной ошибки по модулю не более 0.5
//возвращаемый результат должен быть равен 65536,
//что не укладывается в 16 бит.
uint32_t isqrt(uint32_t x)
{
if (x == 0) return 0;
@stanislavvv
stanislavvv / dnsmasq.conf
Created September 8, 2020 12:47
dnsmasq add ip to ipset forward to tor
...
### .onion and "Flibusta" via TOR
ipset=/onion/tor
ipset=/flibusta.net/tor
ipset=/flibusta.is/tor
...
@stanislavvv
stanislavvv / set_freq
Last active April 12, 2020 11:27
set scaling_max_freq for all cpu in system
#!/bin/bash -eu
# set max cpu scaling frequency
# get limits in MHz
declare -r MIN_KHZ=$( cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_min_freq )
declare -r MAX_KHZ=$( cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq )
declare -r MIN_MHZ=$(( MIN_KHZ / 1000 ))
declare -r MAX_MHZ=$(( MAX_KHZ / 1000 ))
@stanislavvv
stanislavvv / yam-reindent
Created August 29, 2018 12:37
yaml reindent script
#!/usr/bin/python
import sys, yaml
yaml.safe_dump_all(yaml.load_all(sys.stdin), sys.stdout, default_flow_style=False)
@stanislavvv
stanislavvv / remount.py
Last active June 12, 2022 02:02
example script for mount/remount directly from python
import ctypes
import os
def mount(source, target, fs, options='', flags=0):
ret = ctypes.CDLL('libc.so.6', use_errno=True).mount(source, target, fs, flags, options)
if ret < 0:
errno = ctypes.get_errno()
raise RuntimeError("Error mounting {} ({}) on {} with options '{}': {}".
format(source, fs, target, options, os.strerror(errno)))
@stanislavvv
stanislavvv / systray.tk
Last active August 24, 2017 06:44
exec command and set ballon for systray icon
#!/usr/bin/wish
array set fonts {
main {-*-fixed-bold-r-*-*-13-*-*-*-*-*-iso10646-1}
}
# default command:
set command exec
lappend command curl
lappend command -s
@stanislavvv
stanislavvv / raven-shell
Created April 20, 2017 10:58 — forked from barroco/raven-shell
Send Sentry error from shell using curl
#!/bin/sh
SENTRY_KEY=
SENTRY_SECRET=
SENTRY_PROJECTID=1
SENTRY_HOST=sentry.example.com
SCRIPT_ARGUMENTS=$@
capture_error()
{