My first IOS game CombiMath is released. (App Store Link)
(Accompanying web site - http://combimath.com/, visit it from cellphone to take full advantage of it.)
It's a "calculate 24" game. I made the same game for web 3 years ago using Google AppEngine (link). For IOS, I tried to make it using HTML5 wrapped in UIWebview so that I don't have to use Objective-C. But I wasn't satisfied with the end result of that effort. So I bite the bullet and start learning Obj-C. Turned out it wasn't so bad. Objective-C is quite easy. I also used Cocos2d, a popular 2D IOS game engine, which simplified a lot of things.
I'm glad it's out of the door. I need to add game center with leader-board and battle mode in the next release.
10/24/12
9/30/12
Video formatting for PowerPoint embedding
If you have problem embedding videos into your PowerPoint presentation, here's some help.
You need to convert your video to a format PowerPoint accepts. However even if you are able to embed your video and play it on your computer, it doesn't mean it will be playable on other computers.
I tried quite a few combinations of video/audio format (h264, mp3, aac etc.) and found the least common denominator of video/audio format that can be embedded in PowerPoint and played on almost all windows computers is wmv2/wmav2. So here’s command for video conversion with ffmpeg:
ffmpeg -i video1.mov -vcodec wmv2 -acodec wmav2 -f asf video1.wmvThe resulting video quality is usually not very good, the images are often pixelated. To get better video quality, you need to specify bitrate:
ffmpeg -i video1.mov -b 1500k -vcodec wmv2 -acodec wmav2 -f asf video1.wmvHere I specified 1500kbps bitrate. You can set higher bitrate. Of course it doesn’t make sense to go above the video’s original bitrate. You can find the a video’s original bitrate from ffmpeg output or on Windows, right click the video file and select “Properties” then “Details” tab. Try different bitrates and select a lower one while still maintaining an image quality. Often times, I want to keep my video (and therefore the size of PowerPoint) small by shrinking the video (e.g. 320x240) like this:
ffmpeg -i video2.mp4 -vcodec wmv2 -acodec wmav2 -f asf -s 320x240 video2.wmvSmall video has an marginal benefit besides small file size: because the image size is small, the effect of pixilation is markedly reduced. Even with smaller size, with several videos in the Powerpoint, the file can still be too large to be sent with email(gmail and yahoo mail have 25Meg limit). To solve this problem, I usually just embed small, low quality, incomplete “teaser” videos with notes and links to complete 1080p videos I (pre)uploaded on youtube. To cut a 30 second video, starts from 5 seconds at original video:
ffmpeg -i 027.MOV -ss 00:05 -t 30 -vcodec wmv2 -acodec wmav2 -f asf -s 480x270 027s.wmvMy original 1 minute 1920x1080 video is 180MB, the half-minute “teaser” video is only 1.1MB.
9/29/12
How to add watermark to animated gif
I absolutely hate seeing all those watermarks on animated gif's. What am I going to do about it? I will teach you how to add your own.
Here are the steps:
1, make a watermark image.
a, create an image contain your text using a drawing program(I use mspaint on windows). I usually set background (or fill with color) to black, and text color to white, and save as monochrome bmp file.
b, open your image from Gimp(a popular free image editor), add alpha to layer, change layer name from “background” to something else. Then add layer with transparency, use the magic wand(fuzzy select) then cut the black out.
c, resize as needed, then save as “watermark.gif”.
2, make/get an animated gif, resize as needed (use Gimp’s “Transform Tools->Crop” and/or “Images->Scale image”), save as “input.gif”
3, combind input gif and watermark using ImageMagick
1, make a watermark image.
a, create an image contain your text using a drawing program(I use mspaint on windows). I usually set background (or fill with color) to black, and text color to white, and save as monochrome bmp file.
b, open your image from Gimp(a popular free image editor), add alpha to layer, change layer name from “background” to something else. Then add layer with transparency, use the magic wand(fuzzy select) then cut the black out.
c, resize as needed, then save as “watermark.gif”.
2, make/get an animated gif, resize as needed (use Gimp’s “Transform Tools->Crop” and/or “Images->Scale image”), save as “input.gif”
3, combind input gif and watermark using ImageMagick
convert input.gif -coalesce -gravity SouthEast -geometry +5+5 null: watermark.gif -layers composite -layers optimize output.gif4, profit! (or induce gif watermark hatred)
6/9/12
Disable IPv6
We had World IPv6 launch day last week, when major websites and ISP turn on IPv6 permanently. I also have a IPv6 enabled for my server, but the problem is it's not working. When I tried to get a file with wget, I got:
Connecting to iweb.dl.sourceforge.net|2607:f748:10:12::5f:2|:80... failed: Connection timed out.So instead of using "wget", just use "wget -4" to force wget using IPv4. Problem solved? Actually no. When I do apt-get or "gem install", I have no way to tell it to use IPv4. So I just do this to disable IPv6 on my server completely:
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6Sorry, da internet, when both you and I are ready, I will turn on IPv6 again.
6/6/12
Find RPM for a certain file
I need to install GHC7.4.1. But the version of GHC that come with Fedora 16 is 7.0.4. So I did a "yum remove ghc" to uninstall it. But GHC (/usr/bin/ghci) was still there. I then found the command for looking up a RPM associated with a certain file is "rpm -q --whatprovides filename_fullpath". So I did:
rpm -q --whatprovides /usr/bin/ghc, it tells me the RPM name is: "ghc-compiler". I then "yum remove ghc-compiler" to uninstalled GHC 7.0.4 and proceeded to install GHC 7.4.1.
6/5/12
Stop IPsec Policy Agent
My Win Vista laptop's disk activity light kept flashing to no end. Something was killing my disk. I opened "Reliability and Performance Monitor" and found a service called "svchost.exe (LocalSystemNetworkRestricted)" was to blame. After some poking around I found this's not Superfetch, Windows Search, or font Cache. It's "IPsec Policy Agent". I stopped this service, my "Disk % Highest Active Time" dropped from 100% to 0-1%, and stayed here. The disk activity indicator light stopped flashing.
I disabled this service. If later I need to do VPN, I will probably have to re-enabled it again. Hope I remember it.
3/26/12
Using Namecheap SSL with Nginx
I used to use Godaddy and Startcom SSL. Now I just use Namecheap's Comodo PositiveSSL. It's inexpensive - $9/per year, and the installation is pretty straight-forward.
Here are the steps:
1, Buy Comodo PositiveSSl from Namecheap
2, Create domain private key and certificate signing request.
Let's suppose your domain name is example.com
The reason we use example.com.key.nopass instead of example.com.key to generated the signing request is that so we don't need to enter a password everytime you start/restart nginx.
3, Login to Namecheap/Your SSL certificate, click "Activate". You will be asked to select the server type. Just select the first one - Apache/OpenSSL (even though we are using Nginx). You then are asked to paste the certificate signing request (CSR). On your server, do a "cat example.com.csr", and copy and paste the everything (including "----BEGIN..." and "----END...") to the Namecheap web page's text-area. click submit. You will then be asked enter additional information, enter them.
4, You will receive a email from Comodo asking you to open a link and paste some code that's provided in the mail. Do that.
5, After some time (30 minutes to a few hours), you will get your certificate in email. Download the zip file. It contains 3 files: example_com.crt, PositiveSSLCA2.crt, AddTrustExternalCARoot.crt. You need to concatenate them into a single file:
6, Configure Nginx.
Copy the files example.com.key.nopass and example.com.crt to a certian place, for example /usr/local/etc/nginx/ssl/. In Nginx conf file, point to them:
After that you're done.
Here are the steps:
1, Buy Comodo PositiveSSl from Namecheap
2, Create domain private key and certificate signing request.
Let's suppose your domain name is example.com
#Must do these as root.
openssl genrsa -des3 -out example.com.key 2048
#you will be prompted to enter password
openssl rsa -in example.com.key -out example.com.key.nopass
#you will be prompted to enter password you created in last step
openssl req -new -key example.com.key.nopass -out example.com.csr
#you will be prompted to enter country code (US), State name, City name, Organization name etc. The most important one is "Common Name", it must be the same as your domain name. For those optional item (ones marked as []", just press enter. Don't enter "A challenge password"
The reason we use example.com.key.nopass instead of example.com.key to generated the signing request is that so we don't need to enter a password everytime you start/restart nginx.
3, Login to Namecheap/Your SSL certificate, click "Activate". You will be asked to select the server type. Just select the first one - Apache/OpenSSL (even though we are using Nginx). You then are asked to paste the certificate signing request (CSR). On your server, do a "cat example.com.csr", and copy and paste the everything (including "----BEGIN..." and "----END...") to the Namecheap web page's text-area. click submit. You will then be asked enter additional information, enter them.
4, You will receive a email from Comodo asking you to open a link and paste some code that's provided in the mail. Do that.
5, After some time (30 minutes to a few hours), you will get your certificate in email. Download the zip file. It contains 3 files: example_com.crt, PositiveSSLCA2.crt, AddTrustExternalCARoot.crt. You need to concatenate them into a single file:
cat example_com.crt PositiveSSLCA2.crt AddTrustExternalCARoot.crt > example.com.crt
6, Configure Nginx.
Copy the files example.com.key.nopass and example.com.crt to a certian place, for example /usr/local/etc/nginx/ssl/. In Nginx conf file, point to them:
ssl on;
ssl_certificate /usr/local/etc/nginx/ssl/example.com.crt;
ssl_certificate_key /usr/local/etc/nginx/ssl/example.com.key.nopass;
After that you're done.
3/19/12
old homepage
Just found out the old homepage I had at UTEP still exists in archive.org.
Here're 2 awesome animated gif I pulled from there. Hard to believe I made them in 1997, 15 years ago!
gif1
gif2
The first one run animation 2 times then stop. The 2nd has a transparent background. I don't even know how to make them today without googling around.
Here're 2 awesome animated gif I pulled from there. Hard to believe I made them in 1997, 15 years ago!
gif1
gif2
The first one run animation 2 times then stop. The 2nd has a transparent background. I don't even know how to make them today without googling around.
2/21/12
Lyrics Scroller App
I attended AT&T Mobile App Hackathon in Plano last weekend. I made an iPhone app in less than 24 hours! It's a app that display lyrics while playing a song, it highlight the sentence that's being played, kind of like Karaoke. It's more of a proof of concept prototype. But I will continue working on it and will submit it to App Store. I will also make an Android version.
Here's video demo: (Sorry for the poor video quality. In shooting of this video, the camera went out-of-focus, I tried to manually adjust but that made it worse.)
Here's video demo: (Sorry for the poor video quality. In shooting of this video, the camera went out-of-focus, I tried to manually adjust but that made it worse.)
1/31/12
Compile Objective C 2.0 (objc 2) on Linux
If you have gcc >4.6 (type 'gcc --version' to check your version), you can use gcc, otherwise use clang(llvm).
On Fedora, install dependencies:
To compile:
@property @synthesize works. Blocks also work.
On Ubuntu, install dependencies:
Not all language features are possible on linux, for example @autoreleasepool {} works on neither Fedora nor Ubuntu.
On Fedora, install dependencies:
yum install gcc-objc libobjc gnustep-base-devel gnustep-gui-develIf you want to use llvm, do a "yum install clang"
To compile:
gcc `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lgnustep-base helloworld.m -o helloworldYou have to use clang instead of gcc if you want to use blocks and you have to add '-fblocks' flag.
@property @synthesize works. Blocks also work.
On Ubuntu, install dependencies:
sudo apt-get install gobjc libobjc2 lib32objc2 libgnustep gnustep-base gnustep-devel clangTo compile:
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/4.4/include/objc/ /usr/local/include/objc
clang `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lgnustep-base helloworld.m -o helloworldOn my machine (running Ubuntu 10.04), because gcc version is 4.4, I have to use clang. I also couldn't get blocks to work.
Not all language features are possible on linux, for example @autoreleasepool {} works on neither Fedora nor Ubuntu.
1/18/12
Programming with Chinese 用中文编程
I just found out that I can now use Chinese in filename and as variable name in Visual studio 2010.
1/17/12
2012 Resolutions and other thoughts
7!
That's the number of blog posts I wrote in the last 2 years! Boy do I need to write more often! I will put "write more blogs" as one of my new year's resolutions. No, wait, it's already there. Although it's a bit late for new year's resolutions now that we are over half month into January, I actually had my resolutions written down earlier, in fact, much earlier - like, 5 years ago.
My 2012 new year's resolutions is the same as ones for 2007. Suffice to say I didn't accomplish any of those in 2007, nor 2008, nor, well, you get the idea.
So I won't publish the resolutions again, but they are usual stuffs like everybody else's: stay fit, learn Korean, learn Haskell, save more, spend less, launch X, launch Y, change the world, etc.
That's the number of blog posts I wrote in the last 2 years! Boy do I need to write more often! I will put "write more blogs" as one of my new year's resolutions. No, wait, it's already there. Although it's a bit late for new year's resolutions now that we are over half month into January, I actually had my resolutions written down earlier, in fact, much earlier - like, 5 years ago.
My 2012 new year's resolutions is the same as ones for 2007. Suffice to say I didn't accomplish any of those in 2007, nor 2008, nor, well, you get the idea.
So I won't publish the resolutions again, but they are usual stuffs like everybody else's: stay fit, learn Korean, learn Haskell, save more, spend less, launch X, launch Y, change the world, etc.
Subscribe to:
Posts (Atom)