Skip to content

Instantly share code, notes, and snippets.

View u8sand's full-sized avatar

Daniel Clarke u8sand

View GitHub Profile
@u8sand
u8sand / QtUiCleaner
Created December 24, 2014 00:20
Sometimes Qt Creator doesn't clean up after itself--this should take care of that.
#!/bin/python3
import sys;
from lxml import etree;
def clean(f):
print("Processing "+f+"...")
tree = etree.parse(f)
root = tree.getroot()
used_actions=[]
@u8sand
u8sand / random_file_tree.py
Created June 4, 2015 14:28
Random File Tree
#!/bin/python
"""
This script was made to generate a big and random
file/folder structure quickly and easily.
Made by u8sand
"""
# util functions
@u8sand
u8sand / tofromovpn.py
Created December 16, 2015 16:21
A simple and easy script to convert to/from open vpn's embedded format (ovpn)
#!/bin/python
import argparse
import re
parser = argparse.ArgumentParser(description='Convert to and from ovpn files')
parser.add_argument('file', type=str, help='the .config or the .ovpn')
args = parser.parse_args()
m = re.match(r'(.*)\.(ovpn|conf)', args.file)
@u8sand
u8sand / downsample.py
Last active November 23, 2019 16:50
Downsample lines in a file, useful for csv's that are too big.
#!/bin/python
'''
Usage:
python downsample.py [offset+]amount
Examples:
cat super_big.csv | python downsample.py 1+4 > big_divided_by_4.csv
cat data.csv | python downsample.py 2 > data_halved.csv
'''
import sys
@u8sand
u8sand / lvm2csv.py
Created February 21, 2016 01:31
Multisim Generated `.lvm` file conversion to `.csv`
#!/bin/python
import sys
for i in sys.stdin:
if i.find('Comment') != -1:
print(','.join(i.split('\t')), end='')
break
for l in sys.stdin:
print(','.join(l.split('\t')), end='')
@u8sand
u8sand / truth.py
Last active May 10, 2016 11:53
Generate simple n-bit truth tables
''' Generate a truth table '''
from itertools import product
import sys
args = sys.argv[1:]
if args!=[]:
bits = int(args[0])
sep1 = '\t' if len(args)<=1 else args[1]
sep2 = '\n' if len(args)<=2 else args[2]
print(sep2.join([sep1.join(map(str,l)) for l in product(*[(0,1)]*bits)))
@u8sand
u8sand / baka-input.py
Created March 15, 2016 20:05
A prototype of the baka input handler
class Input(Data):
data = ['key', 'mouse']
class Key(dict, Data):
data = ('data', 'input',)
def __init__(self, parent):
dict.__init__(self)
self.input = parent
@u8sand
u8sand / settings.cpp
Created March 15, 2016 21:25
The new settings class: exploiting JSON and QMetaProperties
#include "settings.h"
#include <QFile>
#include <QVariantMap>
#include <QJsonDocument>
#include <QMetaProperty>
#include "util.h"
Settings::Settings(QObject *parent):
@u8sand
u8sand / no-overlay.patch
Created March 16, 2016 12:22
Patch for removing all overlay code
diff --git a/src/overlayhandler.cpp b/src/overlayhandler.cpp
index db5819a..17e97cf 100644
--- a/src/overlayhandler.cpp
+++ b/src/overlayhandler.cpp
@@ -32,137 +32,137 @@ OverlayHandler::OverlayHandler(QObject *parent):
OverlayHandler::~OverlayHandler()
{
- for(auto o : overlays)
- delete o;
@u8sand
u8sand / rn.sh
Created March 31, 2016 13:28
Rename files to lowercase
#!/bin/bash
# e.g find . -type f -exec bash rn.sh {} \;
p=$(dirname "$1")
f=$(basename "$1")
l=${f,,}
mv "$p/$f" "$p/$l.tmp"
sync