Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
Typing

Juntong Liu Towdium

🤖
Typing
View GitHub Profile
@Towdium
Towdium / nuclear.py
Created Feb 21, 2020
Simple script to calculate resource usage of Nuclear Craft breeding
View nuclear.py
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 / global
Last active Feb 15, 2020
Toggle on/off global proxy with v2ray Dokodemo based on iptables
View global
#!/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 / PassiveTree.java
Created Nov 4, 2019
One deprecated implementation in PinIn since its slowness in construction and high memory consumption
View PassiveTree.java
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 / lang2json.py
Last active Oct 13, 2019
Convert Minecraft language file from properties to JSON format
View lang2json.py
import sys
import codecs
usage = '''
Usage: python lang2json.py some.lang
Python 3 please
'''
def convert(file):
View PosNegMergeSort.java
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 / worktimer.py
Last active Sep 19, 2018
A simple program to keep your neck and waist healthy
View worktimer.py
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
@Towdium
Towdium / hex2mif.py
Last active Mar 16, 2018
A script to convert hex instructions to Quartus .mif files
View hex2mif.py
'''
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
'''
View convtran.py
"""
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*$')
View vwf2svg.py
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
'''
You can’t perform that action at this time.