Comment Frenzy

Rainbow of 1000

Quickly generated text with this java program:

import java.util.Arrays;

public class Rainbow {
	/*
	 * Any color is an int triple of r, g and b value
	 * */
	
	final static int[] RED = new int[] {0xee, 0x00, 0x00};
	final static int[] ORANGE = new int[] {0xee, 0x7e, 0x00};
	final static int[] YELLOW = new int[] {0xee, 0xee, 0x00};
	final static int[] GREEN = new int[] {0x00, 0xee, 0x00};
	final static int[] BLUE = new int[] {0x00, 0x7e, 0xee};
	final static int[] PURPLE =new int[] {0xee, 0x00, 0xee};
	
	/*
	 * transition vectors
	 * */
	final static int[] REDTOORANGE = new int[] {ORANGE[0]-RED[0], ORANGE[1]-RED[1], ORANGE[2]-RED[2]};
	final static int[] ORANGETOYELLOW = new int[] {YELLOW[0]-ORANGE[0], YELLOW[1]-ORANGE[1], YELLOW[2]-ORANGE[2]};
	final static int[] YELLOWTOGREEN = new int[] {GREEN[0]-YELLOW[0], GREEN[1]-YELLOW[1], GREEN[2]-YELLOW[2]};
	final static int[] GREENTOBLUE = new int[] {BLUE[0]-GREEN[0], BLUE[1]-GREEN[1], BLUE[2]-GREEN[2]};
	final static int[] BLUETOPURPLE = new int[] {PURPLE[0]-BLUE[0], PURPLE[1]-BLUE[1], PURPLE[2]-BLUE[2]};
	final static int[] PURPLETORED =new int[] {RED[0]-PURPLE[0], RED[1]-PURPLE[1], RED[2]-PURPLE[2]};
	
	/*
	 * indexing colors and transition vectors
	 * */
	
	final static int[][] COLORS = new int[][] {RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE};
	final static int[][] COLORDIFFERENCES = new int[][] {REDTOORANGE, ORANGETOYELLOW, 
		YELLOWTOGREEN, GREENTOBLUE, BLUETOPURPLE, PURPLETORED};

	public static void main(String[] args) {
		
		
		String in = "";
		for(int i=0; i<1000; i++) {
			in+="█";
		}
		
		System.out.println(rainbowformat(in));
		
		
	}

	public static String rainbowformat(String in) {
		/*
		 * Not doing anything when less than 6 characters are put in
		 * */
		if (in.length() < 6)
			return in;

		/*
		 * Calculating colors for each character via linear interpolation.
		 * Before that the string is split as the difference vector changes after the split part
		 * */
		String[] splitstring = splitString(in, 6);
		String out = "";
		for(int i=0, index = 0; i<6; i++) {
			for(int j=0; j<splitstring[0].length(); j++, index++) {
				
				int color = colorToHex(new int[] {
						(COLORS[i][0] + j * COLORDIFFERENCES[i][0] / splitstring[0].length()),
						(COLORS[i][1] + j * COLORDIFFERENCES[i][1] / splitstring[0].length()),
						(COLORS[i][2] + j * COLORDIFFERENCES[i][2] / splitstring[0].length()),
						});
				
					out += ("[color=#" + padHex( Integer.toHexString(color)) + "]" +
				( (index < in.length()) ? in.charAt(index) : "")
				+ "[/color]");
				
				
				
			}
		}
		
		return out;
	}

	public static String[] splitString(String in, int parts) {
		
		/*
		 * Splitting the string to an array with the parts
		 * */
		
		if (in.length() < parts) {
			return new String[] {};
		}

		final int ONE_NTH_OF_STRING_LENGTH = in.length()%parts >= parts/2 ?  in.length() / parts +1 : in.length()/parts;
		String[] out = new String[parts];

		for (int i = 0; i < out.length; i++) {
			out[i] = "";
		}

		for (int i = 0; i < parts; i++) {
			for (int j = 0; j < ONE_NTH_OF_STRING_LENGTH; j++) {
				int currentIndex = ONE_NTH_OF_STRING_LENGTH * i + j;
				if (currentIndex < in.length()) {
					out[i] += in.charAt(currentIndex);
					
				}
			}
		}
		System.out.println(Arrays.toString(out));
		return out;

	}

	/*
	 * Color-Hex calculations
	 * */
	
	public static int colorToHex (int[] c) {
		
		return c[0] * 0x10000 + c[1] * 0x100 + c[2];
	}
	
	public static String padHex(String hex) {
		if(hex.length() >=6 ) return hex;
		int numberOfZeroes = 6-hex.length();
		String padding = "";
		
		for(int i=0; i<numberOfZeroes; i++) {
			padding+="0";
		}
		
		return padding + hex;
		
	}
}

8 Likes

Ayo I just earned regular status let’s go! :3

8 Likes

Ok nice! Well REE REEEEE!

9 Likes

And I got demoted to Member :skull:

10 Likes

Rip that actually sucks :frowning:

8 Likes

just saying we have reached post 20,000

7 Likes

Why do statistic say we have only 9K topics?

7 Likes

idk i check the amount we have by the urls


side note, we got to 10,000 posts around August 2021. that means that the first 8 years (112 months) of the DG forums made 10,000 posts and the next 14 months made 10,000 posts. truly a testament to _________________

7 Likes

IMG_20221209_202526
Some random screenshot I have.I don’t know why,when or how but it’s in my album.

8 Likes

I actually recognize SE of this because I kinda know how to code basic Java scripts, very interesting!

7 Likes

testing a bug for discourse meta

6 Likes

what the heck i just installed the fig client for the dark gaming and meta forum and i get spammed with notifications

7 Likes

RANDOM.ORG - String Generator Generated at here random strings and spammed them in spam channel and one contained “BanUK”

5 Likes

lol

4 Likes

Who is :wastebasket: deleted?

6 Likes

probably a shiden alt that tried to join the forums

6 Likes

Did they spam reports such as “Glasia entering A, B, C, C, C, C, D, F, F, H, I, J, M, M, N, N, P, P, R, R, S, T, T, V, W, W word” ?

6 Likes

Aparently, I got a random DG video on the main page, Weird considering i haven’t watched anything dg related or terraria (With exception of nate themes, but yet these are tagged as music rather than games)

6 Likes

Created an own reaction test tool exporting results to own file format:

Reaction test class:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main {

	static boolean presskey = false;
	static long startTime = System.currentTimeMillis();
	static JFrame jframe = new JFrame();
	static JLabel text = new JLabel("Wait...");
	static int round = 1;
	static int maxrounds;
	static JLabel remaining;
	static final int DEFAULT_ROUND_AMOUNT = 5;
	static final String filename = "Reaction Test Results of "
			+ DateTimeFormatter.ofPattern("yyyy-MM-dd HH-mm-ss").format(LocalDateTime.now())
			+ ".glasia";

	public static void main(String[] args) throws Exception {
		/*Determining the amount of rounds, by default it is 5*/
		try {
			maxrounds = !args[0].equals("") ? Integer.parseInt(args[0]) : DEFAULT_ROUND_AMOUNT;
		} catch (NumberFormatException | ArrayIndexOutOfBoundsException f) {
			maxrounds = DEFAULT_ROUND_AMOUNT;
		}
		
		/*Generating the test window with the start text.
		 * The test starts with the program start*/
		remaining = new JLabel(Integer.toString(Main.maxrounds) + " remaining");
		jframe.add(remaining);
		remaining.setFont(new Font("Arial", Font.BOLD, 20));
		jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jframe.getContentPane().setBackground(new Color(200, 0, 0));
		jframe.addKeyListener(new MKeyListener(new File(filename)));
		jframe.setSize(600, 300);
		jframe.setVisible(true);
		
		
		/*After a random amount of time the window turns green
		 * and the user is prompted to press any key
		 * of their keyboard.*/
		while (round < maxrounds) {
			int waittimems = new java.util.Random().nextInt(1000) + 1000;
			TimeUnit.MILLISECONDS.sleep(waittimems);
			startTime = System.currentTimeMillis();
			jframe.getContentPane().setBackground(new Color(0, 200, 0));
			remaining.setText("Press any key!");
			presskey = true;
		}

	}
}

/* Listener class for the keyboard presses*/
class MKeyListener extends KeyAdapter {
	long avgReactTime = 0;
	final String FINAL_TEXT = (char) 0 + "Glasia" + (char) 0;

	FileOutputStream fos;
	DataOutputStream dos;
	File f;

	/* Constructor for the listener of key presses
	 * to attribute different instances to different elements
	 * but in this class there is only the window itself*/
	public MKeyListener(File f) {
		try {
			this.fos = new FileOutputStream(f);
			this.f = f;
			this.dos = new DataOutputStream(fos);
			dos.writeLong(System.currentTimeMillis());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			System.out.println("File not found");;
		} catch (IOException e) {
			System.out.println("IO error");
		}
	}

	@Override
	public void keyPressed(KeyEvent event) {
		/*If the key is pressed while the screen is green,
		 * the system calculates the reaction time and writes it as a long
		 * to a test file. If the last round is done, the window closes.
		 * The test file ends with 20_103_889_150_370_048, 0x00476C6173696100,
		 * in strings (NUL char)Glasia(NUL char). Additionally the measurements
		 * are printed to the console*/
		try {
		if (Main.presskey == true) {
			Main.presskey = false;
			long delay = System.currentTimeMillis() - Main.startTime;
			String roundmsg = "Round " + Main.round + "/" + Main.maxrounds + ": " + "Reaction time: " + delay + " ms";
			System.out.println(roundmsg);
			avgReactTime += delay;
			dos.writeLong(delay);
			Main.jframe.getContentPane().setBackground(new Color(200, 0, 0));

			Main.remaining.setText(Integer.toString(Main.maxrounds - Main.round) + " remaining");
			Main.round++;

			if (Main.round > Main.maxrounds) {
				avgReactTime /= Main.maxrounds;
				dos.writeLong(avgReactTime);
				dos.writeLong(20_103_889_150_370_048L);
				System.out.println("Average reaction time: " + avgReactTime + " ms");
				Main.jframe.dispatchEvent(new WindowEvent(Main.jframe, WindowEvent.WINDOW_CLOSING));
				System.exit(0);
			}
		}
		
		} catch(IOException e) {
			System.out.println("IO error");
		}
	}
}


Reaction test results reader class
import java.awt.BorderLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.time.Instant;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Read extends JPanel implements ActionListener {

	private static final long serialVersionUID = -1153916116263103596L;
	JButton openButton;
	JTextArea log;
	JFileChooser fc;

	public Read() {
		super(new BorderLayout());

		log = new JTextArea(5, 20);
		log.setMargin(new Insets(5, 5, 5, 5));
		log.setEditable(false);
		JScrollPane logScrollPane = new JScrollPane(log);

		fc = new JFileChooser();
		openButton = new JButton("Open a File...");
		openButton.addActionListener(this);

		JPanel buttonPanel = new JPanel(); 
		buttonPanel.add(openButton);

		add(buttonPanel, BorderLayout.PAGE_START);
		add(logScrollPane, BorderLayout.CENTER);
	}

	/* Convert the bytes of the own file type to text
	 * that is displayed as a result in the text box.
	 * The test file ends with 20_103_889_150_370_048, 0x00476C6173696100,
	 * in strings (NUL char)Glasia(NUL char). This is the magic number of the end
	 * of the test file*/
	public String readFromFile(File f) throws FileNotFoundException {
		if (!f.toString().endsWith(".glasia")) {
			return "File could not be read";
		} else {
			FileInputStream fis = new FileInputStream(f);
			DataInputStream dis = new DataInputStream(fis);
			String out = "";
			long avg = 0;
			for (int i = 0;; i++) {
				try {
					long rounds =  (f.length() - 8)/8;
					long l = dis.readLong();
					if (i == 0) {
						
						String datetime = Instant.ofEpochMilli(l).toString();
						datetime = datetime.substring(0, 10) + " " + datetime.substring(11,19);
						out += "Reaction Test Results of " + datetime + "\n";
					} else if (l == 20_103_889_150_370_048L) {
						out += "Average: " + (avg/(rounds-1)) + "ms\n";
						dis.close();
						return out;
					} 
					else{
						avg+=l;
						out+="Round " + i + "/" + (rounds-1) + ": " + l + " ms\n";
					}
				} catch (EOFException e) {
					System.out.println("End of file reached");
				} catch (IOException e) {
					System.out.println("IO error");
				}
			}

		}
	}

	/* Button click listener */
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == openButton) {
			int returnVal = fc.showOpenDialog(Read.this);
			/* If user selected a file it creates the file instance*/
			if (returnVal == JFileChooser.APPROVE_OPTION) {
				File file = fc.getSelectedFile();
				try {
					log.append(readFromFile(file));
				} catch (FileNotFoundException e1) {
					e1.printStackTrace();
				}
			} 
			log.setCaretPosition(log.getDocument().getLength());

		}
	}

	

	/*Creating the window, putting the content and displaying it*/
	private static void createAndShowGUI() {
		JFrame frame = new JFrame("FileChooserDemo");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(new Read());
		frame.pack();
		frame.setVisible(true);
	}

	/* Starting the window */
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				UIManager.put("swing.boldMetal", Boolean.FALSE);
				createAndShowGUI();
			}
		});
	}
}
7 Likes

This was 2:03:00 before my birthday

7 Likes