Browse Category

Programming Languages

Automatically fill in verification code in course selection system login page

Verification code is broadly used in different websites to ensure the contents are only accessible by humans instead of bots. The course selection system in my college has also been added a verification code field in the login page to reduce momentary load of its server. (by slowing down everyone’s time to fill in the code and hit log in)

Besides that, the system was kindly designed a “Play Audio” button as well for visually impaired people to “hear” the verification code. However, there is a defect that we can take advantage of the “Play Audio” button function to fill in the verification code programmatically for us.

Since I have done my last course selection in my college life, I will demonstrate how to fill in the verification code by exploiting the “Play Audio” button function in below.

Keep Reading

[Matplotlib] Multiple axes with different scales

It’s quite often we will output the chart of the records that a neural network have played during training a neural network playing games.

As the records grows, the chart becomes crowded and is difficult to see how the line graph grows.

Therefore, we come up with a strategy that we only plot out the average of each 250 records in our chart.

Keep Reading

[Java] Convert SQL ResultSet to JSON Array

JSON is a handy format while dealing with data in front end. However, the default return type of querying data via JDBC is ResultSet.

Fortunately, below is the method I found to convert SQL ResultSet to JSON Array.


Remember to import.

import org.json.JSONArray;
import org.json.JSONObject;
import java.sql.ResultSet;

The convert method.

public static JSONArray convert(ResultSet resultSet) throws Exception {

	JSONArray jsonArray = new JSONArray();

	while ( {

		int columns = resultSet.getMetaData().getColumnCount();
		JSONObject obj = new JSONObject();

		for (int i = 0; i < columns; i++)
			obj.put(resultSet.getMetaData().getColumnLabel(i + 1).toLowerCase(), resultSet.getObject(i + 1));

	return jsonArray;


Where I found the code.