Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
wait_for_hosts () {
for host in $@; do
while ! timeout 5 bash -c "echo > /dev/tcp/${host//:/\/}"; do
echo "$host is not available. Retrying..."
sleep 2
done
echo $host is available!
done
@Gordin
Gordin / putio_pcloud_sync.py
Last active January 29, 2019 20:57
Script to Sync files from put.io to pcloud
# Get Put.io Key with the AuthHelper and fill in PCLOUD/PUTIO variables
# putio_pcloud_sync.py list
# putio_pcloud_sync.py filter 'START OF ONE OF THE list OUTPUTS'
# putio_pcloud_sync.py sync 'START OF ONE OF THE list OUTPUTS' 'PATH IN PCLOUD'
import sys
import asyncio
import putiopy
from pcloud import PyCloud
from sh import mv, rm, aria2c
@Gordin
Gordin / no_librarian_while_playing_beat_saber.ahk
Created October 3, 2019 17:10
Disables the OVRLibrarian program from Oculus while Beat Saber is running. (Needs to be run as administrator)
#Persistent
SetTimer, beatsabercheck, 2000
process_name := "Beat Saber.exe"
Librarian := "C:\Program Files\Oculus\Support\oculus-librarian\OVRLibrarian.exe"
Librarian_bak := "C:\Program Files\Oculus\Support\oculus-librarian\OVRLibrarian_bak.exe"
beatsabercheck:
ifWinExist, ahk_exe %process_name%
{
@Gordin
Gordin / twitter_asterisk_fix.rb
Created February 15, 2020 02:42
Fix for the twitter gem that allows Tweets with * in them
require "uri"
# The encoder method of the http gem needs to be overriden because of the twitter gem.
# Without that, there's an incompatibility between the simple_oauth gem which encodes asterisks and the http one which does not.
# Cf. https://github.com/httprb/form_data/issues/22 and https://github.com/sferik/twitter/issues/6# 77
# I added a check to see if this method has been called from inside the twitter gem, so that other libraries can still use the default behavior
HTTP::FormData::Urlencoded.encoder = lambda do |enum, enc = nil|
call_regex = Regexp.new(
'gems/twitter-\d+.\d+.\d+/lib/twitter/rest/request.rb:\d+:in `public_send\'')
if caller.any? call_regex
@Gordin
Gordin / cd_for_windows_paths.sh
Last active September 7, 2024 04:53
If you put this in your .bashrc/.zshrc you will be able to use cd to Windows style paths. This is probably only useful for WSL users.
cd() {
# Check if no arguments to make just typing cd<Enter> work
# Also check if the first argument starts with a - and let cd handle it
if [ $# -eq 0 ] || [[ $1 == -* ]]
then
builtin cd $@
return
fi
# If path exists, just cd into it
# (also, using $* and not $@ makes it so you don't have to escape spaces any more)
@Gordin
Gordin / covid_mortality.py
Last active March 21, 2020 14:55
Script to calculate mortality rate of COVID-19 in different countries based on data from https://coronavirus.jhu.edu/map.html
#!/usr/bin/env python3
# Little script to calculate the mortality rate of COVID-19 in different
# countries based on data from https://coronavirus.jhu.edu/map.html
# I extracted this from firefox dev tools. Returns country data as JSON
'''
curl 'https://services9.arcgis.com/N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?f=json&where=(Confirmed%20%3E%200)%20AND%20(Deaths%3E0)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=Deaths%20desc%2CCountry_Region%20asc%2CProvince_State%20asc&outSR=102100&resultOffset=0&resultRecordCount=250&cacheHint=true' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Origin: https://www.arcgis.com' -H 'Connection: keep-alive' -H 'Referer: https://www.arcgis.com/apps/opsdashboard/index.html' -H 'TE: Trailers'
'''
# Build the same request in python
@Gordin
Gordin / .bashrc
Created June 19, 2020 14:36
Make Tab-Completion usable in WSL by removing Windows stuff from PATH
# If in WSL, remove all windows stuff from path, except Windows dir for explorer.exe
# This Speeds up Tab-completion A LOT. without this pressing TAB takes ~8.5 seconds, with this
# ~100ms. Change /mnt/\c\/ to something different if the Windows drive is mounted somewhere else...
C_DRIVE='/mnt/c'
if [ -d "$C_DRIVE" ]; then
export PATH=$(echo ${PATH} | \
awk -v RS=: -v ORS=: "/${C_DRIVE//\//\\/}/ {next} {print}" | sed 's/:*$//')
# Add C:\Windows back so you can do `explorer.exe .` to open an explorer at current directory
export PATH="$PATH:$C_DRIVE/Windows/"
fi
@Gordin
Gordin / encode.ps1
Created October 11, 2020 18:29
Normalize audio and upscale to 4K in one go with ffmpeg-normalize, using NVENC Encoder in Powershell
$files = Get-ChildItem "E:\obs\convert\"
foreach ($file in $files) {
$name = $file.name
ffmpeg-normalize $file.fullName -o "E:\obs\converted\${name}_4k.mkv" -e='-vf scale=3840:2160 -c:v hevc_nvenc -rc constqp -qp 14 -rc-lookahead 8' -pr
}
@Gordin
Gordin / lid.sh
Created December 5, 2020 01:55
script, that moves windows to another monitor, when the lid of the notebook is closed. Run with `watch -n 0.5 ./lid.sh`
#!/usr/bin/env bash
LID_TMP='/tmp/lidscript.tmp'
# Read hoved windows from file
readarray moved_windows < $LID_TMP
# remove newlines after every element...
newMovedWindows=()
for i in "${!moved_windows[@]}"; do
without_newline=${moved_windows[$i]%$'\n'}
if [[ $without_newline != "" ]]; then
@Gordin
Gordin / README.md
Last active May 23, 2024 02:36
Script that remaps Keys in Cyberpunk 2077 from qwertz to dvorak and shifts everything one key to the right (to play with ESDF)
  1. Have python installed
  2. Download remap.py and put it next to the config file inputUserMappings.xml (Should be in ...\Cyberpunk 2077\r6\config)
  3. Open a terminal, cd into the directory with the script, and run python remap.py
  4. It should create a new file called inputUserMappings2.xml
  5. Now rename inputUserMappings.xml to something else, and rename inputUserMappings2.xml to inputUserMappings.xml