Skip to content

Instantly share code, notes, and snippets.

@ynsta
ynsta / par2protect.py
Last active March 16, 2016 15:17
Protect files in each directory recursively using par2. It repairs and updates with par2, if only adler32 sum of files does not match.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import zlib
import ctypes
import subprocess
DESCRIPTION = 'Protect files in directories recursively with par2.'
@ynsta
ynsta / .bashrc
Last active August 29, 2015 14:02
bashrc: absdir and setenv functions
function absdir() {
for i; do
python -c "import os; print os.path.abspath('$i')"
done
}
function setenv() {
for env ; do
if [ -d "${env}" ]; then
env=$(absdir "$env")
@ynsta
ynsta / git-delivery.sh
Created June 11, 2014 20:02
bashrc: git-delivery shell function
function git-delivery() {
git status >/dev/null || return 1
dtag=$(git describe --abbrev=0 --tags 2>/dev/null | git log -1 --pretty='%h')
dext='tar'
for i; do
case $i in
-h|--help)
cat <<EOF
usage: git-delivery [tag] [ext]
@ynsta
ynsta / WellerRTProto.ino
Created July 1, 2014 23:14
Weller RT Station PID Protoype
#define TEMPERATURE 350
#define TEMPERATURE_MAX 400
#define PWM_PIN 3
#define PWM_MAX 245
#define PID_INT_MAX (500)
#define PID_INT_MIN (-PID_INT_MAX)
#define TEMP_GAIN 0.42
@ynsta
ynsta / sampler.py
Last active June 8, 2023 15:33
Statistic profiling on stm32f4 with openocd by dwt_pcsr sampling
#!/usr/bin/python2
# run openocd (0.9.0) with :
# $ openocd -f stlink-v2-1.cfg -f stm32f4x.cfg &> /dev/null"
# then run
# $ python2 sampler.py path_to_myelf_with_symbols
import sys
import time
import telnetlib
@ynsta
ynsta / stm32f7x.cfg
Created June 24, 2015 22:09
OpenOCD 0.9.0 config for STM32F746G-DISCO target (stm32f746ng)
# script for stm32f7x family
#
# stm32 devices support both JTAG and SWD transports.
#
source [find target/swj-dp.tcl]
source [find mem_helper.tcl]
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
@ynsta
ynsta / blur.sh
Last active September 28, 2022 18:26
Blur konsole and yakuake instead of simple transparency
# add to zshrc
function blur-konsoles() {
windows=($(qdbus org.kde.konsole 2>/dev/null | egrep '^\/konsole\/MainWindow_[0-9]+$'))
for win in ${windows}; do
winId=$(qdbus org.kde.konsole $win winId 2>/dev/null)
[ ! -z "${winId}" ] && xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id "${winId}"
done
qdbus org.kde.yakuake &>/dev/null && xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -name Yakuake
}
[ ! -z "$KONSOLE_DBUS_WINDOW" ] && blur-konsoles
@ynsta
ynsta / json2vdf.py
Last active September 25, 2017 22:03
Steam vdf/json converters
#!/usr/bin/env python
import json
def json2vdf(stream):
"""
Read a json file and return a string in Steam vdf format
"""