TIL how to indent within WordPress code snippet without plugin

After tons and tons of googling, and almost giving up, I finally found out how to do two things:

  1. Add code snippets / blocks to WordPress posts with syntax highlighting
  2. How to indent lines

All of this without installing any plugins!

To begin the code snippet / block, use the following code:

And to indent, add the ASCII code for <tab> which is :

The above code will be rendered as follows:

for x in y:
	print x

TIL How to do web scraping / crawling

Grandma (on my mother’s side) passed away this Monday. She had been ill for some time…she was getting better, but her condition took a turn for the worse, and she passed away.

Went to 연천 yesterday to bury her ashes. May she rest in peace.

Today was my first day back at work after the funeral. I was gone for three days, but boy has a lot happened in that time. Over the weekend before the funeral, I was tasked with working on Korean measure words and how to extract them from our corpus data. I tried out some regex scripts, but never really got to review them together at work.

Today I got a new task: web scraping / crawling. I’m not sure if those two words are synonymous. At any rate, I was eager to learn something new (I’m always learning…does one ever stop?)

I was given some reference material and code to learn and work off of. It was some code for scraping data off of a search query from Daum. It did take me more than half of my day to dig in and figure out what was going on with the code.

I was glad to learn about Beautiful Soup, however. I had heard and read the (weird) sounding library/module, but never had a chance to check it out. I’m learning something new everyday, and more often than not, I feel overwhelmed. But I’m working to push through to keep learning and not get too discouraged. I keep reminding myself that it hasn’t been too long since I began coding in earnest, and that it takes time to get my skills up to a decent level. I’m only starting out.

That shouldn’t be my excuse though.

I also learned about the requests module, using which I could pull and make HTML requests. It was cool to use commands like the following to easily grab the source code of HTML pages:

from bs4 import BeautifulSoup

import requests

r = requests.get('http://www.bbc.com/news/world-us-canada-40816708')

data = r.text

soup = BeautifulSoup(data, 'lxml')

for link in soup.find_all('a'):

I found myself looking through a ton of HTML code. First time in a long time. I first dabbled in HTML and CSS back in high school, when I learned a bit at school. It was cool using the Chrome Developer tools to see which parts of the HTML code corresponded to which section of the webpage.

I’ve still got some ways to go to be able to web scrape with confidence, but I’m glad to see that I’ve made at least some progress so far. I want to share some links that I’ve found helpful.

Web Scraping

This page is all in Korean, but I learned some things. He explains how the BS4 module get_text() works.

Using the requests module


Multi-line print options in Python.

I saw the end='' option argument used inside the print function, but didn’t know exactly what it did. This really showed me how this works.

for i in range (3):
	print(i, end='')

The meaning of “main
The following if statement was in the code, and some googling helped me understand how this works:

if __name__ == "__main__":


Use of ‘global’ keyword for variables


urllib module


Use of .format

I had no idea you could do something like this! It feels quite similar to using %s.

print ("First Module's Name: {}").format(__name__)
First Module's Name: __main__


잘한다! 자란다! – Korean pronunciation tricks in a subway ad

KakaoTalk_20150129_092930682Came across this ad on the subway the other day. It’s an ad for some university, but it was the copy that caught my interest.

The words 잘한다 (to be good) and 자란다 (to be growing), while spelled differently, sound identical when said at a normal speech rate. To go along with the image of the trees, I presume the message is that going to this university will help you excel and grow.

But back to the pronunciation. Korean shows this kind of pronunciation. Of interest here is that when ㄹ is adjacent to ㅎ, the sound of the ㅎ virtually disappears. This can be seen in other words like 발휘 (to exhibit, show a skill, etc.), which again, when pronounced at normal speech rates, is pronounced as [barwee] as opposed to [barhwee].

Another example is 옳다, which means ‘to be correct’. Here it’s a little different because this time it’s a syllable-final consonant cluster ㅀ, but the same principle seems to apply whereby the sound of the ㅎ is overruled by the sound of the ㄹ.

This happens in combinations of ㄴ and ㅎ as well, such as in words like 인하 (to reduce) and 반하다 (to fall for something, someone). At normal speech rates, both are pronounced usually as [inah] and [banada] as opposed to [inha] and [banhada], as the spelling would suggest.

This copy just caught my interest because it made use of this little pronunciation trick. I’m all for smart copies like these.

Getting to know Japanese / 日本語

Japanese is one of those languages that has been on my list for some time now.

Despite its proximity to my native Korea (and one might argue, grammatical proximity), I never did get around to learning it.

On the one hand, I honestly did not see much practical use for learning it, and it wasn’t the case that I watched Japanese anime or was really into Japanese games, either. I guess I did play a lot of Japanese-made games, but there never really was a need for me to learn Japanese.

In university, I picked up an introductory book on Japanese because our bookstore was having a sale. I got it real cheap, so I decided to take advantage of it and try to learn some Japanese.

I read through the first bit, and focused on trying to learn the characters – Hiragana and Katakana, of course.

The key to learning new characters or a new alphabet is lots and lots of repeated exposure, but I never really got into the habit of reviewing the characters, so I never really learned them at all.

Fast-forward a few years. In October 2013, I decided to take introductory Japanese lessons at a hakwon (language school) with my girlfriend. My girlfriend wanted to learn it, and I figured since I like languages, learning, and at the same I could get to know my girlfriend better, I decided to join her.

The classes were basically three months of basic, introduction to Japanese for absolute beginners. Classes were 4-hour sessions every Saturday, but I could take classes during the weekdays as well. My girlfriend and I opted to take Saturday classes because we both had to work during the weekdays.

The first few classes, first month was a breeze. To get going, we had to really work at learning the Hiragana, but because we read Hiragana all the time (there was no Romaji), we got the hang of it pretty quick.

At this point in time, I don’t quite remember what we learned point-by-point, but initially, I felt like I could use Korean grammar as a reference point to understand Japanese grammar. Japanese, like Korean, is an agglutinative language, meaning that you add on little markers that indicate the role of that word in the sentence. This helped a lot to get a grasp of the language.

For obvious reasons, it really helps a lot to have a reference language you can sort of lean back on and compare. Currently, I don’t know any Slavic languages, but I’m sure knowing one Slavic language will help me in learning another Slavic language.

Back to Japanese. Into the second month, we started learning about verbs and how to conjugate them. We learned that there are three groups of verbs depending on the verb stem, and how to conjugate them into the basic -ます ending. The biggest and most important component of the second month was learning the verbs and how they work. We also learned expressions and connectives along with the verbs. By connectives I mean things like ~ので, ~でも. Then in the third month, we just did more verb endings, went into a little bit of honorifics and humble language. I was surprised to learn that Japanese has a very complex honorifics system. Much more complex than Korean, for sure.

After the 3 months of introductory Japanese, I was ready to take conversation class. I managed to pass an interview with a Japanese native speaker and get into a conversation class with a native speaker. It was my first time in a real Japanese conversation class, after 3 months of basic Japanese grammar. For better or for worse, our Japanese conversation teacher didn’t really speak any Korean nor English, for that matter. So I found myself in a completely Japanese-only environment. I was quite overwhelmed at first, trying to decipher everything that the teacher was telling me. There were two other people in the class with me, but they had had experience in a conversation class like this for some time, and had already studied the conversation book we were using.

Immediately, I realized I didn’t know enough words, and that I didn’t know enough Kanji. Because I didn’t know the words and didn’t know the Kanji, I really couldn’t read stuff in the book and the handouts she gave out. Most times, I tried to decipher the first Kanji character in a verb or something and figure out the meaning of the verb. But since I didn’t know how to pronounce the Kanji, I couldn’t read it. Overall, it was a great experience being able to converse with a native speaker of Japanese for the first time, albeit with my limited speaking abilities.

I unfortunately did not take another class after that, and I’ve just been listening to Japanese conversations on LingQ, picking up a few words here and there. I do want to focus more on Japanese once I get some clear goals in mind where I want to take Japanese, what I want to do with Japanese. As of late, I’ve been listening to Japanese on LingQ and brushing up on the grammar I learned in the first three months at the hakwon. When I first learned about the three verb groups, it was quite mentally overwhelming to take in everything all at once, but now as I listen to LingQ and gradually internalize the verbs and words, and see it contextualized in an authentic conversation, I’m getting it a lot more. So I’m combining listening to authentic Japanese content and doing a little bit of grammar review on the side. I feel like once I get more familiar with the verb conjugation system, after that, it’s all words and expressions. And I’m taking advantage of my (limited) knowledge of Chinese characters to guess at/identify meanings of nouns and verbs I find in my Japanese listening. Perhaps studying Chinese and Japanese at the same time could be beneficial?

I actually thought of registering for Phone Japanese. In Korea, a lot of people sign up for Phone English where they can have a 10 minute conversation with a native speaker every day. I was thinking about maybe trying that with Japanese, so I can actually utilize what I know and just hit the ground running to gain more vocabulary. Oh well, hopefully, I can try posting something in Japanese in the near future.

Learning French in Togo

In December 2011, I decided to volunteer in Togo in West Africa.

I had a choice between Ivory Coast and Togo, but I went with Togo because I wanted the chance to explore a country that I had never heard of before.

Why Togo of all places? Because Togo is a French-speaking country. Rather than going to an English-speaking country, I wanted to use this opportunity to live French!

When I first arrived in Canada, I wanted to learn French, knowing that Canada is a bilingual country. But I was already a sophomore, and given that I knew no French at all, could not join a class of students who had been learning for a few years.

So at the time, I went out and bought a Teach-Yourself French book that came with CDs for pronunciation. I tried to work through the book, listening to the CD. But I gave up because I thought it was too hard. So French always remained on my list of languages that I wanted to learn, but I guess I never got around to it.

Fast forward a few years, and I found myself in Lomé, the capital of Togo. Togo is a narrow strip of land located in West Africa bordered on the west and east by Ghana and Bénin. I learned that it used to be under German control, and then came under the control of France following Germany’s defeat in the Second World War.

There are around 40 different languages spoken in the country, but it seemed to me that Ewe was the most common, apart from French of course. French was the lingua franca in the country, used in all areas of life, and being used as the intermediary language between different tribes who could not otherwise communicate.

Shortly after my arrival, the other volunteers and I took classes in elementary French. As with most classes, we started with the alphabet and practiced pronunciation. Fortunately, our teacher was an elderly Togolese gentleman who had taught French to the American Peace Corps, and was an eager and patient instructor.

In the first 2-3 months of learning the language, I was working on getting the pronunciation right and practicing the verbs we had learned. Given that I was surrounded by French speakers 24/7, I had so many people to practice with. And given that our lives centered around a daily routine, the things we needed to say were also limited to a set of phrases.

I must say that my knowledge of Spanish did serve me usefully. For instance, it occurred to me while learning the tenses, that some of them, while not identical, were comparable enough such that knowing the conjugations in Spanish helped me more easily acquire the French counterparts.

For example, the simple future tense in French and Spanish seemed similar to me:

être                                                          ser
Je serai                                                    Yo seré
Tu seras                                                   Tú serás
Il/elle sera                                                 Él/ella será
Nous serons                                             Nosotros seremos
Vous serez                                               Vosotros seréis
Ils/elles seront                                          Ellos/ellas serán

This and other similarities between Spanish and French certainly peaked my interest.

In the initial stages of learning the language, I found myself inadvertently mixing in Spanish words amidst the French; for instance, I would find myself saying something like “J’ai besoin de _____ para laver les habits.” The correct word here would be pour, not para.

Another thing was accent. Togolese French is accented in a way that is distinct from say, French of Côte d’Ivoire or Bénin. In particular, the “r” sound, that is uvular in Parisian French, was not produced in the same way by the Togolese. It was rolled by some, and somewhat aspirated by some.

I also heard expressions like “C’est comment?” alternated with “(Comment) ça va?”. Apparently, the former expression is used frequently in the French-speaking African countries. I was met with amused expressions when I uttered this expression in front of French people.

After 5-6 months of living in Togo, I was able to express myself in the range of what I needed to say; that is, in the daily routines of my volunteer duties. in other words, given the range of topics one could talk about, I couldn’t say all that much, but I could speak to the Togolese and joke around as well. During this time, I continued reading this French book I was working on. It was a elementary-level children’s book with pictures, and at the beginning, I literally had to look up more than half the words on the page. But as I started to understand the sentences, the story came alive to me in my brain, and reading the book stopped becoming a chore. I learned a lot of words from this book that I would probably not use ever again, words like anchor, sail, etc., but it was all good practice acquiring new words.

I also tried reading Petit Nicolas, and this book was a great deal easier than the other book, and the stories were cute and funny. I guess one might think reading children’s stories might not be “realistic” language, but given my level at the time, I was quite happy reading about these kids’ adventures as their level of vocabulary and range was suitable enough for me.

I also attempted reading some of Les Misérables in the original French, but now this was a whole different playing field. I got worn out just from looking up all the words, and even when I did look up the word, I would likely forget the meaning of the same word once I got to the text or when the same word appeared in the next few paragraphs.

I also listened to French conversations that I found on LingQ every now and then to keep my ears attuned to French. Now this type of French was more like Parisian French, and so I had difficulty even understanding the basic things they said. Togolese French is quite different. To my pleasant surprise, by the end of 10-11 months, and thereafter when I came back, I found that I could understand those conversations with ease.

Once I got back from Togo, I decided not to let my French go to waste and signed up to take the DELF exam, level B2. Seeing as how I had to do some writing, and given that I didn’t really “formally” learn French, I signed up for some DELF B2 prep classes through Alliance française, which were extremely helpful in preparing for the exam. I took the exam and fortunately, passed.

Nowadays, given that I have been focusing my efforts on Chinese, I haven’t been able to work on French all that much, but I do like to keep it up by going to LanguageCast and speaking to French speakers and listening to conversations on LingQ every now and then. I do want to make plans to get C1 or C2 level in French as well sometime in the future. Maybe I’ll try writing some posts in French as well for practice 🙂

A long-overdue update

A lot has happened since my last post here (November 2011).

I picked up French while volunteering for 11 months in Togo, and took 4 months of beginner level Japanese.

And as of late, I have been working more intently on HSK level 5, hoping to take the exam in October this year. Chinese has been my primary obsession these days, focusing on learning the characters and also delving deeper into the philosophical world ensconced within the black strokes.

I will make separate posts on how I learned French in Togo, about learning Japanese, and my ongoing studies in Chinese in the next few posts.