Author Archives: brandonio21

The Power of Markup Languages

An Anecdote

Recently, I’ve been trying to make myself learn how to write rich documents within plaintext files. I want to do this for a few reasons:

  • I can write everything in vim. Let’s face it — Word processors are pretty ugly. I really don’t like working on documents in Microsoft Word or LibreOffice when I can instead work on my documents in vim. Not only the look, but also the speed. I am able to edit so much faster using vim than any other editor on the market.
  • Portability is key. Have you ever received a paper from a colleague only to be found that it is in some format that you can’t read? (Cough Pages Cough). I, personally, really hate when this happens. In order to solve the problem, why not just write everything in plaintext and distribute it that way?
  • It prepares for the future. In the future, Microsoft Office, Pages, LibreOffice, and the like will probably be out the window. In fact, Windows, Mac OSX, UNIX, or anything you hold dear in the computing world will probably be thrown out the window. If this is the case, the text that we write needs to be unformatted. That way, the text can be viewed on any operating system with any text editor.

The Solution

The solution, I have found, is to write everything using Markdown (Using the CommonMark Spec) and LaTeX. In this way, I will be able to express all of my thoughts in a clear, succinct, portable, and easy-to-read fashion.

One of the great things about these two markup languages is that they are everywhere. You don’t really know until you start using it without thinking, but almost every program supports it. It’s great expressing your thoughts in Skype or GChat because you can bold important words or italicize others. What a good way to express your thoughts!

Because of my recent change in heart, I will be writing all of my blog posts in plaintext from now on and leaving it to the WordPress text rendering system to render everything (hopefully properly). There are also many, many plugins making LaTeX and Markdown rendering possible. It’s really great.

Look how easy it is to express my favorite finite automata:
$M_{favorite} = {Q, \Sigma, \delta, q_{0}, F}$
M_{favorite} = \{Q, \Sigma, \delta, q_{0}, F\}

I will probably report back about this venture as I learn more.

Why Everyone Should Learn Latin

One of the first posts on this blog discussed the interest that I had in reading pieces written by writers who lived some 2,500 years ago, mainly those who lived in ancient Rome. The post can be found here.

One of the main things that I found to be interesting about reading the works of those who wrote complex anecdotes in Latin is that the topics they discussed are extremely similar to the topics that are discussed and debated about today. For instance, authors often joked about the cruelty of the government, discussed the meaning of life, and wrote reports on the actions and customs of other nations. As a race and society as a whole, we are often claimed to have advanced by an incredible amount; however, upon analyzing the texts of ancient Roman writers, we learn that, especially with social issues, we have barely turned a pebble.

The Grammar

Before I even delve into the world of social issues and Latin, I want to discuss how much of a benefit learning Latin is from a linguistics perspective. To put things in perspective, most people I know are native English speakers; however, they do not know the inner workings of the language. For instance, ask them to construct a sentence using the pluperfect. Most will just sit and stare. “What’s a pluperfect?”. Exactly.

After learning a good bit of Spanish, I always thought it was weird how they put so much emphasis on the conjugation of verbs. Every time you used a verb you have to conjugate it? How strange!! How naïve I was. We conjugate verbs in English, too! (He runs, I run, they run) – it just took Latin to really hammer this idea into my head.

Latin has also taught me a lot about how other languages are able to work. I always figured that all languages work in a strict subject+verb pattern. That is, just like English. However, Latin showed that word order doesn’t even have to matter! Word order is just a preference in some languages, and endings of words determines what is the subject and what is the verb. This allows authors to declare their own style and allows for a true freedom of language. For instance, take the following example of English and Latin.

I ran with my friends.

Ego cum meis amicis cucurri.

As you can see, the English works in a subject+verb structure, where the additional information is provided after the fact. In Latin, the subject is at the beginning of the sentence, the verb at the end, and all additional information is packed in the middle. It really is different from English and shows the true stylistic differences that exist between the two languages.

Before I get talking about the social implications of Latin, I just want to mention that learning Latin has also allowed me to become more knowledgeable about other things in English such as the cases of words, moods of verbs, tenses of verbs, and many, many word roots that are very interesting. (Presidio is derived from the Latin word Praesedens meaning “stand before” – translating into something that stands before other things or defends!)

 

The Social Implications

Think of the world. Think about your existence. Think about the people around you. They all have their own standards, morals, thoughts, and ways of life. Now think about the people that existed before you. Do they have their own standards, morals, and thoughts? Surely. Now think about the people that lived in ancient Rome. Do they have standards, morals, and thoughts? Most people would not imagine so. Most people could not even imagine them living in the same way that we live today (I know I have difficulties with this).

Reading Latin opens your mind to this. Reading the thoughts and words of people who lived in ancient Rome makes one come to the realization that even 2,500 years ago, people were just like we are today. They loved their wives, family, and children. They squabbled over the same things. They came home every night for dinner. It is simply hard to imagine that they lived out a daily life, though. One often thinks of Romans in battle, in court, or attending some sort of toga party, but one never thinks of Romans as people who woke up in the morning, pondered the details of life, and went to bed at night.

Isn’t it weird to think about that? Some many thousands of years ago, a whole different set of people walked the Earth, and they thought and ate and used the restroom just like we do today. Realizing this thing was very humbling to me. All of this realization was able to occur due to the stories, opinions, and anecdotes that I read.

Discovering all of these things was a wonderful and unexpected side effect of learning Latin. I believe that it has led me to a much more open mind and has allowed me to look at the world, especially humanity, in a whole new light. Because of this, I recommend that everyone learn Latin. Learning Latin is learning more about the humble origins of modern humanity.

Instantly Filling a Progressbar in .NET

I ran into a problem the other day while working on an application. Sometimes the Progressbar that monitored an event would not fill in as fast as the event completed. Thus, in order to get the progressbar to instantaneously fill, simply specify a value that is below the current value.

For example,

progressbar.Value = 100;
progressbar.Value = 99;
progressbar.Value = 100;

Will instantly fill the progressbar object to 100%. Hope this helps!

Building an Offline Program with Online Syncing

As I become more and more experienced with software development, I am very quickly discovering the limitations of the web. Having a desktop application that constantly needs to retrieve large amounts of data from the Internet is very, very slow. Sometimes, when network speeds are spotty, a simple interaction can take up to 30 seconds, which is definitely unacceptable for the end-user.

In order to solve this problem, I decided to restrict myself from looking at online solutions. I wanted to create a solution on my own.

First, I wanted to create a robust system for managing a database for an offline program. I looked into several different services, including Microsoft’s SQL Stack and a local MongoDB server. However, I found that most of these solutions were either too difficult to learn (I was used to setting up a MySQL server using cPanel and phpMyAdmin) or that they over-complicated the issue. Then, I came across SQLite, which happened to be exactly what I was looking for. It was a lightweight, speedy, local replica of MySQL. After spending about an hour reading the documentation, I realized that it was also super easy to setup. I began working on a library that would make working with a local SQLite database super easy.

Thus, SQLiteDatabaseManager was born. The project was meant to house functionality that would be used in all of my projects, and here are some of the key features that were packed into it:

  • The ability to quickly create a local database
  • The ability to quickly insert, delete, and update records knowing the table names, the fields, and the new values.
  • The ability to have a small table-verification system that allowed the user to define table schemas and check the existing SQLite tables against these schemas for integrity verification.
  • The ability to retry operations when they fail (the fail could be a result of a spontaneous locked file and a retry could fix everything)

SQLiteDatabaseManager worked well because all you needed to do was create a new instance of it, and everything worked out of the box. A new SQLite database was setup and managed by the library. After rigorous testing, this worked perfectly. Of course, the library still needs major work and many more features, but it does what it was intended to do at the moment. My offline data management system worked.

Now the problem was not just managing data offline, but getting it to sync to an online counter-part when a network was available (In a perfect world, all operations would be done on the local SQLite database (fast) and then they would be replicated on the duplicate remote MySQL database (slower) on a background thread). The idea was simple.
Local SQL and Online SQLThe SQLite database and the MySQL database would communicate with eachother via a simple REST API. The databases would be identical and the ID numbers created by the SQLite database would simply be moved to the MySQL database.

 

Creating the REST API for the remote MySQL portion of this project was rather simple. Relying on the methods of the LAMP stack, I used a set of PHP files that would receive GET, POST and DELETE requests so that data could be managed and manipulated fairly easily. Using PHP’s json_encode() function also proved very useful for creating readable responses.

Thus, with the creation of a working SQLite local database and a working and accessible remote MySQL database, I went ahead with the first iteration of implementing this idea. So far, I have run into a few problems.

 

An easily-solvable problem arose when thinking about how to handle many, many clients. Since there was only one remote MySQL database and many, many instances of the local SQLite database, it was a pain tracking when the local client’s changes actually had to be applied or if the remote version was actually newer. This problem was solved by creating a dateAltered field in both the remote and local databases that would contain the last date of modification of the data that it pertained to. Thus, the data with the latest dateAltered value was put permanently into the remote MySQL database.

But what about when there are many, many clients creating information. Surely, some of the client’s SQLite databases will assign ID numbers that coincide with other clients’ SQLite databases. Thus, when information is uploaded to the remote server, different pieces of information may have the same ID numbers. But since all data is modifiable, how is this detectable? This is a problem that I have not yet worked out a solution to since the first implementation of this design has a one-client one-server relationship. However, at the moment, I am hypothesizing that each data-entry contain a unique hash of its original state. Thus, database operations can be performed by referencing the ID of the element, but conflict-resolutions will use this hashed code. Thus, we will always be able to track if a certain piece of information has been modified from its original form or not. Thus, when uploading to the remote server, the server will manage some conflict resolutions and return the ID number of the object. The local clients will then reassign the ID number of the object to that ID number in order to match with the remote MySQL database.

 

I will continue to work on this project in the coming weeks, and I plan on making some detailed blog posts about it, so stay tuned! Eventually, I hope to have this process wrapped up in an easy-to-install and easy-to-implement library. We will see how that turns out.

 

Humanity is Good.

There are many, many events that make me doubt the goodness and the heart of humanity as a whole. Of course, this is definitely an over-generalization and there are definitely occurrences that make me realize that there are a lot of good people in the world.

I want to describe one of those occurrences.

If you do not know, I am currently employed at a Dining Hall here on campus. Although I have no interest in working in the food service industry, I thought that it would be a good experience getting to know the ins and outs of the businesses that so happily serve us food almost every day of our lives. So far, it has been a very rewarding experience, and I definitely recommend an employment in the food service industry to everyone who frequents restaurants.

Now, back to the story. I was working the cash register as usual. Everyone was diligently paying for their food and getting water cups. Nothing out of the ordinary. Then, a woman with sunglasses and a skateboard approached the cash register. Once again, nothing out of the ordinary. Then, she kindly offered to pay for the four customers after her in line, of whom she informed me she did not know. I’ve never experienced someone offering to pay for strangers before, so this was a transaction that I was extremely glad to make. I thanked the woman, told her how kind she was, and sent her on her way with her food.

The expressions of the people who had their food paid for were priceless. First, a look of awe and embarrassment. A poor man was under the impression that the woman had attempted to pay for his food as some sort of sign that she was interested in him. However, when he learned that the next person was also being paid for, he become less embarrassed and more appreciative of the gesture that this stranger had made. The next individual in line curiously waited to see if the person behind him was also being paid for, and when he realized that they were, he left. Whether this was because they knew eachother or that he was simply concerned that the person behind him would get the short end of the stick, I’ll never know.

The third person to be paid for did as expected: They take their prepaid food and left. The fourth person, however, did something that has inspired me to be a better person everyday. He asked me about the person behind him. “Is the person behind me’s meal paid for as well?”. Of course, I responded with a “No.” To this, the customer gladly stated that he would pay for the person behind him. Not only did this customer get a free meal, but he also cared enough about the people around him to make sure that he wasn’t the only one getting something for free.

This trend surprisingly continued for the next 10-or so people. Each one, after learning about their free meal, was immediately concerned with the status of the person behind them. After learning they hadn’t been paid for, they quickly offered to pay. Of course, there was bound to be someone who did not take the time to check on the person next in line, but the fact remains that a single act of gratitude, paying for the next four people in line, sparked a huge chain of people who were looking out for one another and taking care of each other’s meals.

This event made me extremely excited, and I immediately told my roommates about the event when I returned home. Inspired by it, my roommate actually decided to surprise me and pay for my laundry that night. In order to give back the good feeling, I decided to pay for someone elses’ laundry, to which they were very receptive, and we have become good friends.

This event has taught me that people, no matter how ignorant, arrogant, or self-centered they may seem, have a lot of good in them, and are very capable of accomplishing astonishing things. Because of this event, I am now inspired to look out for anyone else who may need help and immediately offer my assistance. On top of this, I think it’s a good idea to surprise people once in a while. I want to show those around me that I care about them.

Now I challenge you, reader, to go out and do the same. Pay for a stranger’s meal. Help a stranger carry something. Offer your aid wherever you think it could be useful. It could make someone’s day, start a chain reaction, and maybe change the world.