Hello guys, welcome back to my blog this week. This week’s blog is inspired by the issue with the task that I am working on. The task is pretty simple and straight forward. I am responsible for building an extension of my school’s official website, and the site needs a text editor where professors could write new announcements for students of their courses. The text editor includes a toolbar lies above the text box that would help professors modify the text easily. Currently, all the icons’ images of the toolbar is loaded from the school’s server. My manager required me to make those icons “server-less”.

After discussed with my manager about the task, I decided to create a JSON file contains all the images of the icons inside the local project itself, not from any external servers. Here is the simple instruction how to create a proper JSON file, read the data from the file, and access it on a Django template:

File structure of the project:


  • images.json
  • app.py
  • images/
  • icons.html

JSON file:
{"title":"Title 1","file":"images/Title1.jpg"},
{"title":"Title 2","file":"images/Title2.jpg"}

import json
with open('images.json') as image_file:
images = json.load(image_file)
icons = images["icons']

In order to access the fields of the JSON file in app.py:

icons.html (it is a Django template, so you will see some Django template tags):
{% for icon in icons %}
{% endfor %}


Hello, all. I am Tuan Pham. First of all, I want to say thank you to you all who visits my blog as well as my first ever blog. Well, few things about me, I am studying Computer Science at the University of Central Florida. I used to be Ruby on Rails developer before I went to college, however, it was a difficult time for me to face the reality that I was not good at programming in general. That was why I decided to choose Computer Science as my major and software development as my career. Besides coding, I also make music especially Electronic Dance Music (EDM) (for anyone who’s curious about the kind of genre I like, I really love House music, and Future Bass).

Today, I am going to share my experience as a Computer Science (CS) student on my Computer Science 1 class at University of Central Florida (UCF). At this moment I am writing those lines, it is 2017 Summer semester at UCF which is really short, about 12 weeks. I have 3 programming assignments that I already finished one (I’ll go through the details of it later), 3 lab problems, and 2 exams with 1 final. The schedule is really tight with 12 weeks and I have to make sure everything is on track and keep the GPA as the score I want. The professor of the class is McAlpin who is not too bad for anyone who just wants to pass the class with a ‘C’. The only problem with him I found is that sometimes he falls into ‘side missions’ which means that he goes over too many details of things around the lecture. For example, he could go over stories of who created that kind of technology or the progress of it. For me, they are pretty awesome stories and I totally would love to hear more, but other students might not think the way that I do. I do not blame him on that because he just wants to make things interesting to students (it sounds cheesy, doesn’t it? Sorry, I am a cheesy guy). Now, we are going to the details of what I have been learning so far in the class. At the first few weeks before the first exam which was on June 15th, the main topics of the class are pointers, dynamic allocation memory, debugging tool like GDB, structure, and big-O notation. One more thing I think I should mention that all the assignments and test problems were written on C. You can find all the code that I have been writing for this class at my Github-CS1.

On pointers, there are two important parts that are how to declare and use pointers and segmentation fault of pointers as NULL pointers and uninitialized pointers. Below is the correct way to declare a pointer and dereference to a variable.
int x = 42, *p;
p = &x;

A new concept of Computer Science that I never knew before is dynamic allocation memory. Before all I knew just was the static memory that declared and used inside the program and, after that I really did not know what happens to them after I finish my program. Now I know that if I call an empty storage from ‘heap’ (free storage from our operating system and others), I would need to free by free() in order to avoid memory leaks (never knew that awesome concept before).
char *name = malloc(15 * sizeof(char));

Based on what I have experienced from my coding jobs, it seems like the structure of the high-level programming languages like Ruby is somehow adopted from the structure of C (that is just my thought; I haven’t looked it up if it’s true or not). The concept of structure in C is pretty important at this moment for the class. Everything is all around how to manipulate the fields of the structure. Honestly, at the beginning, I really had no interested in the structure because it was hard to find the correct way to utilize it as a pointer. However, as I am going through the class, I always try to relate it to other high-level languages such as Ruby to make it feel easy for me. And actually, now I absolutely love it just as the structure of other languages. Here is a simple example of C structure and how to manipulate the data fields.

typedef struct student {
char *name;
int id;
} student;

student *student //declare a student type, just like you declare int x
strcpy(student->name, "Tuan");
student->id = 123;

Now it is the time for the star of the show, big-O notation. As I know, big-O is one of the most important concepts in CS. I also notice that a lot of interview questions of the big tech company like Google or Apple are related to the big-O. When I first read about it, it was really confusing me. I did not really understand how it would affect the program, and how I could use it for the future’s tasks. I also know that even now friends of mine who are taking CS major are still confused about the true definition of the big-O. Nevertheless, the moment that I took the first exam of the class, I just realized how important it is for any programs. It is a measurement tool to for the efficiency of computer algorithms and programs in general. And thanks for whoever created the big-O, it truly makes sense to me now and I totally fall in love with it.

int foo1a(int n) {
int i, x = 0;
for (i = 0; i <= 100 * n; i++)
return x;
} // O(n) | T(n) = 100n, but because 100n or even 1000n does not make it different than n, so big-O is O(n)

The first homework assignment is based on extraction data from an input file like CSV file, transformation, and loading. Let me explain each part of the assignment. I have a CSV file that has all data from Florida’s airports. What I need to do is that I extract those data from the file and put it in an array of structures which each one contains one airport data. After that, I need to manipulate the data in the way that it needs to be printed out to the console or an output file in the exact same way of the given output file. Because of the sensitive rules of the school (sometimes I really don’t know all the rules), I could not post or re-post the assignment on my blog, but I think I provided enough information for anyone who is interested. That was all about the materials have been covered since the semester started on May. I will update all the status of the class on my next blog. The class is going to end on August 3rd, so I am going to keep going with this series “What’s going on with my Computer Science 1 class?” for about two or three more blogs. Lastly, thank you all that stop by my blog and go through with me to this point. The next blog would be next week with new information about the materials and assignments for my CS1 class.