Fix line-endings; Increase portability; Add speedtyper.py
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Discard on use
|
||||
rm $0
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Increase nice and rtprio limits.
|
||||
local user=$(cut -d' ' -f1 <<< $(who))
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Discard on use
|
||||
rm $0
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sudo mkdir -p /etc/X11/xorg.conf.d/
|
||||
echo 'Section "InputClass"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
USERNAME=""
|
||||
PASSWORD=""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
KEYMAP="dvorak-programmer"
|
||||
DEVICE="/dev/sda"
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Discard on use
|
||||
rm $0
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# https://blog.thepoon.fr/osuLinuxAudioLatency/
|
||||
sudo pacman-key --keyserver hkps://hkps.pool.sks-keyservers.net -r C0E7D0CDB72FBE95
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Discard on use
|
||||
rm $0
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "[multilib]
|
||||
Include = /etc/pacman.d/mirrorlist
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#yay -S yaru-gtk-theme yaru-sound-theme gnome-shell-extension-ubuntu-dock
|
||||
#yay -S yaru-icon-theme # needs to be installed seperately for some reason
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# bulk file renamer that you interface with using intermediary text file.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# deadsimple discord bot
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# extracts cover from flac audio file
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# converts code signatures found in ida to ones easily usable in c++ code
|
||||
|
||||
|
||||
97
python/speedtyper.py
Normal file
97
python/speedtyper.py
Normal file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import curses
|
||||
|
||||
|
||||
class Word():
|
||||
def __init__(self, target, x, y):
|
||||
self.target = target
|
||||
self.input = ""
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
|
||||
def get_words(text, max_x, max_y):
|
||||
curr_x = 0
|
||||
curr_y = 0
|
||||
|
||||
words = []
|
||||
for word in text.split():
|
||||
if curr_x + len(word) > max_x:
|
||||
curr_y += 1
|
||||
curr_x = 0
|
||||
|
||||
if curr_y > max_y:
|
||||
print("text too long, scrolling not implemented.")
|
||||
exit(1)
|
||||
|
||||
words.append(Word(word, curr_x, curr_y))
|
||||
curr_x += len(word) + 1
|
||||
|
||||
return words
|
||||
|
||||
|
||||
def main_curses(stdscr, text):
|
||||
curses.use_default_colors()
|
||||
curses.init_pair(1, curses.COLOR_GREEN, -1)
|
||||
curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_RED)
|
||||
|
||||
key = old_max_y = old_max_x = curr_word = 0
|
||||
|
||||
while True:
|
||||
# rewrap words on screen size change
|
||||
max_y, max_x = stdscr.getmaxyx()
|
||||
if max_y != old_max_y or max_x != old_max_x:
|
||||
words = get_words(text, max_x, max_y)
|
||||
old_max_x = max_x
|
||||
old_max_y = max_y
|
||||
|
||||
if key in (curses.KEY_BACKSPACE, 'KEY_BACKSPACE', '\b', '\x7f', 127): # fml
|
||||
words[curr_word].input = words[curr_word].input[:-1]
|
||||
elif key >= 32 and key <= 126:
|
||||
words[curr_word].input += chr(key)
|
||||
|
||||
# increment current word if its completed
|
||||
if words[curr_word].input == words[curr_word].target:
|
||||
curr_word += 1
|
||||
|
||||
# text complete
|
||||
if curr_word == len(words):
|
||||
break
|
||||
|
||||
stdscr.clear()
|
||||
|
||||
for word in words:
|
||||
if word.input == word.target:
|
||||
stdscr.addstr(word.y, word.x, word.target, curses.A_DIM)
|
||||
elif word == words[curr_word]:
|
||||
stdscr.addstr(word.y, word.x, word.target, curses.A_UNDERLINE)
|
||||
else:
|
||||
stdscr.addstr(word.y, word.x, word.target)
|
||||
|
||||
for i, c in enumerate(words[curr_word].input):
|
||||
if i >= len(words[curr_word].target) or words[curr_word].input[i] != words[curr_word].target[i]:
|
||||
stdscr.addstr(words[curr_word].y, words[curr_word].x + i, c, curses.color_pair(2) | curses.A_BOLD)
|
||||
else:
|
||||
stdscr.addstr(words[curr_word].y, words[curr_word].x + i, c, curses.color_pair(1))
|
||||
|
||||
stdscr.move(words[curr_word].y, words[curr_word].x + len(words[curr_word].input))
|
||||
|
||||
key = stdscr.getch()
|
||||
|
||||
|
||||
def main(argv):
|
||||
from argparse import ArgumentParser
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument("input")
|
||||
args = parser.parse_args(argv[1:])
|
||||
|
||||
text = open(args.input).read()
|
||||
|
||||
curses.wrapper(main_curses, text)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import bs4
|
||||
import sys
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# converts youtube subscriptions export .xml to simple text file
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/env python3
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
|
||||
from selenium import webdriver
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests # http requests
|
||||
import bs4 # html parser
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests, bs4, time
|
||||
|
||||
def get_titles(filename, title_type, maxrank):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# reads SteamIDs from ./accounts.txt and outputs ban information into ./output.html
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests
|
||||
import bs4
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests
|
||||
import bs4
|
||||
|
||||
Reference in New Issue
Block a user