[PHP] [C++] A Concise Syntax for Explicit Type Casting

PHP and C++ have a very convenient way to cast types. You don't have to memorize a long list of conversion functions. You just put the target type in parentheses in front of the value. However, this approach seems to have some problems, though I'm not really sure what they are XD...

February 15, 2011 · 1 min

SQL Notes: The Difference Between the ` and ' Symbols

Recently, while writing a program in PHP, I ran into some SQL code, so I looked into it a bit and discovered something beginners easily get wrong: the ` and ’ symbols do different things. When I didn’t know this, and the book’s print was small, it took me two hours to find out it was this small problem…. So I wrote this post to tell everyone that these two really are different. ...

February 11, 2011 · 1 min

Code::Blocks 10.05 - A C/C++ Compiler That Rivals Dev C++, Cross-Platform (Ubuntu, Windows, Mac)

I'm sure you know the Dev C++ compiler. Many schools use it as the platform for teaching C. For example, the computer classes at Taiwan's top high schools seem to use it. But here I want to introduce not Dev C++, but Code::Blocks. Code::Blocks and Dev C++ are both compilers for C (both C and C++). However, if you have been following Dev C++, you may have noticed that it has not been updated in a long time. Code::Blocks is free and open source, just like Dev C++, but it also supports multiple operating systems, including Windows and Linux. So if you want to write C programs on Ubuntu, you can try this software. This tutorial is for Windows only. ...

February 11, 2011 · 3 min

How to Read Windows Environment Variables (System Variables) in a .NET Program - VB.NET Example

Anyone who has written CMD knows about environment variables. They let you easily get information that differs from one computer to another, such as the user name. In CMD, using an environment variable is simple: you just write it in the %environment variable name% format. In a .NET program, though, it isn't that simple. You need to use the Environ function. ...

February 11, 2011 · 2 min

[PHP] mb_convert_encoding: Some API Returned the Wrong Encoding? Convert It!

↑↑This is viewed in Chrome with Big5 encoding. The top is before conversion, and the bottom is after conversion. Yesterday, while playing with the Google Weather API, I found that it has a parameter for setting your language. If you don’t set it, the API returns English in UTF-8 encoding. But if you set zh-TW, it returns Chinese, encoded in Big5. So when using this API, I had to re-encode its return value to UTF-8 before I could use it. After all, there aren’t many Big5 websites left, so yesterday I went looking for the mb_convert_encoding function to do the encoding conversion for me~ ...

February 4, 2011 · 2 min

Google Weather API - Get a Full Week of Weather Data

Google Weather API is something I discovered today. I wanted to add a weather lookup feature to the Plurk bot I've been developing recently, so I searched online for ways to get weather data. My original plan was to read the Central Weather Bureau's web pages and parse the data there. But then I found that both Google and Yahoo offer weather APIs. I preferred the Google Weather API, because it returns XML, which is easier to parse. Yahoo, on the other hand, returns HTML... Also, the Google Weather API lets you specify a city name directly. For example, if I want the weather for Taipei City, I just pass "Taipei" to the API. Yahoo's weather API isn't that simple, though. You have to enter a city code, which means I'd need to look up the code for the city I want before I could use Yahoo's API. ...

February 4, 2011 · 2 min

How to Write Good Code: Indentation, Declaring Variables and Types, and Comments!

Most people who are just learning to program write code with a few obvious flaws. The code usually isn't indented, and it has almost no comments. If you started with a language like VB6, you probably also skipped declaring variable names and types. Code like that can run, but it is a pain to maintain. This article is just my own small opinion, so if I got something wrong, please let me know....

January 29, 2011 · 7 min

[Java] JDK Installation and Java Source Code Compilation Tutorial

Over the past week, I’ve been taking Java, JSP, and SQL courses at Taipei Business College. I had planned to learn Java anyway. A netizen once told me that the languages every engineer needs to know are C++ and Java. I’ve dabbled a little in C++ and can write small programs, but I had never touched Java at all. When my teacher asked whether I wanted to take classes at Taipei Business College, I went right away, very happy about it. I originally thought Java wasn’t very useful. I wanted to learn it because it’s a required skill for engineers, and also because of its cross-platform nature: I could easily write Java programs for desktop and even mobile phones. Android’s basics are also built on Java. But after a few classes, I started to like Java. It gave me the same drive I had when I first learned a programming language. I started staying up until midnight with a book in my hands… It’s the same feeling I had back when I learned VB.NET!! ...

January 27, 2011 · 4 min

[PHP] Getting the Real Download URLs of Wretch/Yam Music with curl-lib

  The UI I designed is clean^^ This program, getting the real download URLs of Wretch/Yam music, was originally going to become a program that automatically generates blog music code. But since many people already run music code generators, one more wouldn't make much of a difference. So instead of building it, I decided to release the code for everyone to look at. Also, if anyone needs to download music from Yam or Wretch, they can download the program, install it on their own server, and run it there....

January 25, 2011 · 3 min

[VB] [C++] Calculating n! (Factorial)

Calculating the factorial of n is very simple. I wrote this program for permutations and combinations: I wanted a rough idea of how many possible answers there would be, so I wrote an n! function to compute the factorial value. A factorial is 123…..n. In a permutation of 5 items, the result is at most 5432*1, which means there are at most 120 possible answers. Below, I’ve made n! into a Function, with a VB version and a C++ version. People who are just starting to learn loops can use this function to practice how loops work. Also, because I was worried that an integer wouldn’t be able to hold the result, I used a string to return the value. When you use this Function, you need to convert the return value to a numeric type first. ...

January 5, 2011 · 1 min