Skip to content

Instantly share code, notes, and snippets.

@Vftdan
Vftdan / turingm.py
Created November 8, 2018 09:55
Turing machine interpreter. Usage: `python turingm.py program.tsv inputs.txt`
import sys
class ParsingException(BaseException):
pass
class TuringException(BaseException):
pass
header = None
data = dict()
dataptr = 0
states = dict()
stateptr = None
G0 X2 Y8 Z0
G1 F60 E.0024
(M98 P1 L30)
G91
G1 X4
G1 Y-.1
G1 X-4
G1 Y-.1
G1 X4
F60
G0 X11.0
G2 X11.0 Y22.0 I0.0 J11.0
G2 X11.0 Y0.0 I-0.0 J-11.0
G0 Z0.1
G2 X11.0 Y22.0 I0.0 J11.0
G2 X11.0 Y0.0 I-0.0 J-11.0
G0 Z0.2
G2 X11.0 Y22.0 I0.0 J11.0
G2 X11.0 Y0.0 I-0.0 J-11.0
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?validation-md5-digest 17f0e79d174143dc72e8ed7517deb334?>
<worksheet version="3.0.3" xmlns="http://schemas.mathsoft.com/worksheet30" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ws="http://schemas.mathsoft.com/worksheet30" xmlns:ml="http://schemas.mathsoft.com/math30" xmlns:u="http://schemas.mathsoft.com/units10" xmlns:p="http://schemas.mathsoft.com/provenance10">
<pointReleaseData/>
<metadata>
<generator>Mathcad Professional 14.0</generator>
<userData>
<title/>
<description/>
<author>Пользователь Windows</author>
@Vftdan
Vftdan / toggleSide
Created November 23, 2018 19:03
"javascript:" bookmarks for vk.com
javascript:void%28%28document.getElementById%28%22side_bar%22%29.style.display%3Ddocument.getElementById%28%22side_bar%22%29.style.display%3D%3D%22none%22%3F%22block%22%3A%22none%22%29%5E%28document.getElementById%28%22page_body%22%29.style.float%3Ddocument.getElementById%28%22side_bar%22%29.style.display%3D%3D%22none%22%3F%22none%22%3A%22right%22%29%29
M107
M104 S200
G28
G1 Z5 F250.0
M109 S200
G21
@Vftdan
Vftdan / Func8.tsv
Last active December 8, 2018 10:40
Turing Machine program for function F(A, B, C) = A and (B equiv C)
Q\A _ * 0 1 x Комментарии
IN halt * l q1 0 l q1 1 l q1
q1 * r LP
LP _ l q2 * r LP 0 r LP 1 r LP x r LP
q2 * n C0 _ l C0 _ l C1
C0 * l q3 0 l C0 1 l C0
q3 * n D1 x l D1 x l D0 x l q3
C1 * l q4 0 l C1 1 l C1
q4 * n D0 x l D0 x l D1 x l q4
D0 * l q5 0 l D0 1 l D0
@Vftdan
Vftdan / toggleMicOneLiner.sh
Last active January 7, 2019 13:33 — forked from nikhilw/toggleMicOneLiner.sh
Toggle mic on-off on a Ubuntu / Linux Mint machine with a keyboard shortcut
#! /bin/sh
# static icon, easier to set as a bash alias or directly use as a single command instead of creating a script file.
amixer -D pulse set Capture toggle | gawk 'match($0, /(Front Left|Mono).*\[(.*)\]/, a) {print a[2]}' | xargs notify-send --hint=int:transient:1 -i "audio-input-microphone" "Mic switched: $1"
@Vftdan
Vftdan / pal2gpl.py
Created August 9, 2019 19:47
Convert pal to gpl palette
#! /usr/bin/env python3
input() #header
input() #version
cnt = int(input()) #number of colors
print("GIMP Palette")
print("Columns: {0}".format(cnt))
print("#")
for i in range(cnt):
print("{0} {1} {2}\tUntitled".format(*(input().split())) + str(i + 1))
@Vftdan
Vftdan / bspwm-unminimize-event.sh
Last active March 1, 2020 18:19
Minimize windows while using bspwm
#! /bin/sh
xev -root | grep '(_NET_ACTIVE_WINDOW)' -B 1 --line-buffered | \
grep '^ClientMessage' --line-buffered | sed -u -e 's/^.*window //; s/,//' | \
while read w; do \
if [ -n "$(bspc query -N -n $w.hidden)" ]; then \
bspc node "$w" -g hidden=off
bspc node $w.fullscreen -t tiled
bspc node $w -l normal
bspc node -a $w
fi