Category Archive
The following is a list of all entries from the Programming category.
Swap without Temporary Variable
Filed in Programming, April 30, 2008, 12:47 pmWhen we’re programming, if we want to swap values of two integer values, the “normal” way we do it would look like:
x = 5
y = 3
temp = x
x = y
y = temp
We need a temporary variable as a container to hold a value first then do the swap.
What if in some situation you can’t use [...]
Solution to Lenovo Y410 Sound Problem On Ubuntu 8.04
Filed in Linux, Programming, April 27, 2008, 4:21 amUpdate 30/04: This script will only make speaker work, but not headphone. As Sam mentioned, there is another easy way to get sound work without installing anything: Suspend your machine and resume. The drawback is you have to do it every time after you (re)boot.
Well, this is another post about Ubuntu 8.04!
As I mentioned before, [...]
Merry Christmas!
Filed in Programming, December 26, 2007, 3:14 pmHey, this is the first christmas for jaux.net, and today is my first boxing day to crash a door. Got nothing but happy holidays :)
Merry Christmas, everyone!
How To Prevent Creating Objects On Heap
Filed in Programming, December 12, 2007, 3:55 pmYesterday I saw a C++ interview question that was asking the interviewees to prevent the clients from creating objects on heap. That is, you write a class and your class users can’t use new to create an object.
Here is my solution:
1
2
3
4
5
6
7
8
9
10
11
class Foo
{
public:
Foo(const Foo& f) {}
static Foo getAnInstance()
[...]
Search for next
Filed in Programming, November 20, 2007, 12:21 pmThis is a VIM tip. I saw it before, but I forgot it after a while. I saw it today, I don’t want lose it again, so I write it down.
When you are going though a document in VIM, you find a word and you want to go to the next same word in the [...]
Solving Cyclic Dependencies Is Hard
Filed in Linux, Programming, November 14, 2007, 12:55 amI am a C/C++ beginner but I’d been already taught that dependency cycles are generally evil since it’s very hard to solve. I haven’t realized how hard the problem is before, because all the works I’ve done are “one file” programs or I can just simply throw all the files into a single gcc/g++ command.
However, [...]
Peter’s Comment on Concurrency
Filed in Programming, October 17, 2007, 11:35 pm“Concurrent program in a single processor computer will only make it slower than its sequential counterpart, but we are looking into the future, so let’s write concurrent programs.”
– Peter A. Buhr
Autoboxing Makes Java Be 99% Object-Oriented
Filed in Programming, October 10, 2007, 2:50 amI remember that back to the early age when I was first beginning to learn the Java programming language, there was a famous quote (in China): Java is a 95% object-oriented programming language..
Why was it? Because Java has primitive types built-in. I have to admit that I both love primitive types and hate them. Loving [...]
Circular Linked List Problem
Filed in Programming, October 7, 2007, 2:06 pmHow to determine a linked list has a cycle without marking any nodes? This is a classical interview question and one of my friend brought it to me.
When I came across the question, I thought that we might count the nodes. If the our counter goes behind the linked list’s size, we could say that [...]