Skip to content

Instantly share code, notes, and snippets.

View Towdium's full-sized avatar
🤖
Typing

Juntong Liu Towdium

🤖
Typing
View GitHub Profile
import svgwrite
import re
import sys
'''
A little script to convert Altera waveform (.vwf) to SVG image
Make sure you have pip package svgwrite installed by 'pip install svgwrite'
Usage 'python vwf2svg.py file_name.vwf'
By the way, python 3 please
'''
"""
Usage: python convtran.py input_name.md output_name.csv/.md
Now supports markdown and csv only
Python 3 please
"""
import sys
import re
re_line = re.compile(r'^\s*-\s*(.+?)\s*[::]\s*(.+?)\s*$')
@Towdium
Towdium / hex2mif.py
Last active April 24, 2023 03:45
A script to convert hex instructions to Quartus .mif files
'''
This script helps to convert hex instructions to Quartus .mif files.
To run it, use "python hex2mif.py input.txt output.mif"
For input file, assuming you are using Mars as assember,
you need to export the binary instruction as hexadecimal text file.
But for any kind of input files, it should work fine as long as
it uses the following format:
DEADBEEF
BAADF00D
'''
@Towdium
Towdium / worktimer.py
Last active September 19, 2018 10:34
A simple program to keep your neck and waist healthy
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QMainWindow, QApplication, QLCDNumber, QWidget, QGridLayout, QPushButton, \
QGraphicsOpacityEffect
from PyQt5.QtCore import QTimer, QRect
from PyQt5.QtGui import QPainter, QPen, QRegion
from datetime import datetime, timedelta
import sys
'''
This short program might provide help to those with neck or waist problems
import java.util.Arrays;
/**
* Author: Towdium
* Date: 22/04/19
*/
public class PosNegMergeSort {
public static void main(String[] args) {
int[] is = new int[]{1, 2, 3, -2, -4, 5, 3, -2, 4, 1, -5, 3};
sort(is);
@Towdium
Towdium / lang2json.py
Last active October 13, 2019 14:11
Convert Minecraft language file from properties to JSON format
import sys
import codecs
usage = '''
Usage: python lang2json.py some.lang
Python 3 please
'''
def convert(file):
@Towdium
Towdium / PassiveTree.java
Created November 4, 2019 12:40
One deprecated implementation in PinIn since its slowness in construction and high memory consumption
package me.towdium.pinin;
import it.unimi.dsi.fastutil.chars.*;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import me.towdium.pinin.elements.Element;
@Towdium
Towdium / global
Last active February 15, 2020 04:11
Toggle on/off global proxy with v2ray Dokodemo based on iptables
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: global [enable|disable]"
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
@Towdium
Towdium / nuclear.py
Created February 21, 2020 14:22
Simple script to calculate resource usage of Nuclear Craft breeding
from collections import defaultdict
duration = 0.5
selections = {
'HEB-248': 2,
'LECm-243': 6,
'LEP-239': 24,
'LEU-233': 12,
'HEU-235': 12
}
@Towdium
Towdium / dsagt.py
Created September 21, 2021 11:59
Prototype of DSAgent - part of DSTest project: the simplist client-driven udp tunneling
import asyncio
import socket
from asyncio.exceptions import IncompleteReadError
from enum import Enum
from queue import Queue
class Type(Enum):
PACKET = 1
SETUP = 2