Friday, May 3, 2013

Running MatLab on command-line mode. What goods does it have?

For those who are wondering about how to run MatLab on command-line mode, here it is:
./matlab -nojvm -nodisplay -nosplash -r "command"

I am new user to MatLab. Basically I was following some instruction for running MatLab code. I ran into a situation where I had to run a compile.m script that invokes gcc, mex, or any other MatLab's C compiler. When I ran the script through GUI version of MatLab, I kept getting errors that wasn't very helpful. Turned out that the same script ran without any problem on the MatLab ran on command-line mode. So yeah, give it a shot!

Oh yeah,
To ease thing out I also created alias on my .bash_rc as follow:
alias matlab_cmd="matlab -nojvm -nodisplay -nosplash -r "

I then can run the script as follow:
matlab_cmd "command"

Thursday, May 2, 2013

Using windows-shared printers on Linux

With Ubuntu 13.04 (possibly also with any of the lower versions I guess), having Linux to use printers shared for Windows is never easier. Just go to your Printers preferences, add a new printer with SMB sharing protocol. Finally type in your printer's IP address there. (eg. for my school's one it's like smb://crux.cs.washington.edu/ps022) and Voila! It lists you all the printer drivers available. Pick one (or pick Generic, if it is not listed) and things should work right away.

One caveat is that if you're printer is of a specified DOMAIN, put it as part of the user name. For example, my school's undergraduate Windows domain (or I guess it's called Workgroup?) is CSEPCLAB, so I'd put CSEPCLAB\username as my username when connecting to the printer through SMB protocol. It's a bit hacky to do the same thing with Mac. But I believe I have a post for it somewhere in this blog.

OSX, Windows, Ubuntu?

I had been a long-time user of OSX for quite sometimes. (+- 4 years) I found its UNIX environment and super-friendly user interfaces to be very useful for especially programming. Macbook's trackpad and keyboard shortcuts have always been my personal favorite as well.
I've always thought that MacBook's so called over-price is actually worth every penny. It has SMS, light sensor, very decent LCD, etc etc.
I still have lots and lots of positive things I'd want to write about MacBook. Software like SizeUp, TextMate, SMC Fan Control, iTerm 2, etc have been easing my life as a programmer so much. Maybe I'll write some articles about how much I loved OSX sometimes.

However, as I am becoming more more into UNIX environment, I've found OSX to not be able to catch up with my needs. First and foremost is because many software applications simply aren't written to work well with OSX! It's inevitable that the main market consumer is still Windows and so many software industry simply writes crappy port of their software for OSX. What I mean by crappy here is lots of memory leaks, not optimized to work efficiently and so on. Sad to say this, but I have to admit that I found my MacBook 5,1 with 8GB of RAM and 2.1 core-2-duo processor to be considerably sluggish compared to a laptop with a similar spec with Windows on it. A very obvious example would be Flash player. Try running a Youtube video on a 5,1 MacBook. Notice how hot your MacBook is? I can't help but to also notice how sluggish it becomes. It's just very annoying sometimes..

On the other hand, since some Linux are open source, the software support is so amazing. For almost every single application that you're searching for, you'd almost always able to find a decent open-source version that substitutes it. It's just amazing to see how much Linux have been growing. Also the driver supports that let things work out-of-the-box is just so sweet... I guess I'll have to write another post dedicated for Linux at some point.

:D
Feel free to start a discussion within this thread. I'm no big fan of one single OS or biased towards any. I have so much positive things to say about Linux, Windows, or OSX. They're just great and bad in their own ways.

Conveniences from cloud-based services

It's 2013 and I just realized how much conveniences I've been taking for granted from cloud-based services. With ever growing power of Internet, we no longer need to worry about forgetting to bring a USB stick drive or an external hard-drive anymore!

Long story short here are the list of apps that has been very useful to ease my life:
1. Google Chrome: Allows bookmarks, passwords, extensions, and tab synchronizations among different devices (PC, Mac, Linux, or even Android!)
2. Gmail: As an Android user, I found it to be very useful that the phone application is very well synced with the web-based interface. All the emails you send, starred, or labeled can be accessed easily from either web or phone interface.
3. Evernote: Note-taking application that works across platforms.
4. Dropbox: Share folders among computers, tablets, etc. It also creates snapshots for updates that are done to the files. One time Dropbox's backup saved me from losing my school programming work.
Dropbox for Android is also very as it allows automatic synchronization of the pictures you take from your phones. Never again scare to lose your pictures.
5. Google Calendar: Peeking at other's schedule, finding free timeslots for meeting among different people, inviting people to a meeting, or simply a reminder that has a pop-up/email notifications through web or Android device. What else can we ask? It's just getting better and better!
6. Google Drive/Microsoft Skydrive: Microsoft Word as a must for each of your computers? Nah! Why bother with hassles of having to carry USB stick around. Just edit, real-time collaborate, and backup your word docs and spreadsheet online! I recently starting to use Microsoft Skydrive because it mimics Microsoft Word even closer than Google Drive.
7. Google Voice: Ever needing to text someone/group of people, looking/adding/editing your phone contacts through computer, do an international calling for a cheap price, or even a local calling/texting for free? Better try voice.google.com

Life is just so much easier with all these services.

Wednesday, December 14, 2011

Network printing in Ubuntu 11.10

When you try to add network printers via System Tools -> Setting -> Printers, there's an error mentioning something about FirewallD being not activated. To workaround this, open terminal and type 'system-config-printer' this would open an alternative printer configurator that works!

Enjoy printing with your Ubuntu!

Monday, November 28, 2011

Mounting Linux hdd (ext4/ext3/ex2) in OSX

As the title says, here's how to mount Linux partition in OSX:
1. Download MacFuse .dmg from http://code.google.com/p/macfuse/
2. Download fuse-ext2 .dmg from http://sourceforge.net/projects/fuse-ext2/
3. Install them respectively.
4. Reboot your computer?
5. Here is the magic terminal keywords to mount your beloved Linux hdd:

a. First do: 'disktool -l' to find out the name of Linux hdd you're interested in. The name is something like disk0s1 or similar.
b. Next: 'mkdir /Volumes/[HD NAME]' replace HD NAME with your choice of your name. (eg. Linux)
c. After that, 'sudo fuse-ext2 /dev/[LINUX HD NAME] /Volumes/[HD NAME]/ -o force' replace the LINUX HD NAME with the name from part a. above and HD NAME from part b. above

Voila! You're beloved Linux partition is now mounted! :)
Tips: You can add a script to your .profile to automate the steps above every time your computer boots up!

Saturday, November 26, 2011

Installing Ubuntu 11.10 on MacBook 5,1 + Tweaks to run it smoother

Previously I had Ubuntu 11.x installed in my MacBook 5,1. However, after I upgraded it to 11.4 (Natty Narwhal) a problem occurred. My Ubuntu didn't boot-up anymore. I googled around and it seemed that 11.4 has problem with video driver that my MacBook uses.
Long story short, I re-installed my whole Ubuntu partition.
Here are some steps of how to do it.

1. If you're triple booting, make sure to have Refit installed. (This is some sort of BIOS emulation for Mac fancy new technology?) But if you're just dual booting, bootcamp is sufficient.
2. If you're planning to install Windows as well, I would recommend to install the windows first before installing the Ubuntu (a lot of people suggest this). Install the Windows using bootcamp as usual.
3. Now to install Ubuntu, burn the image to a cd/dvd, put it inside the disc reader, then reboot your mac. After you hear the boot-indicator beeping sound (before the apple logo), immediately press and hold 'c' (c stands for cd I guess?) This will let your MacBook boots from the Ubuntu image.
4. Make sure NOT to partition your hard-disk from Ubuntu installer! My friend OSX partition was gone because of this. Just to be safe, always partition using DiskUtility.
5. When prompted for swap file during the Ubuntu installation, just ignore it. We don't need it.

6. Now just follow all the installation step prompted and you'll be good to go! :)


Here are several tricks to make Ubuntu 11.10 run smoother. These tricks originally came from different resources I found in Google. I want to share these as they are really helpful. (Thanks to all the original sources)

Wireless card problem:
In some MacBook version, the wifi doesn't work out of the box. To fix this, go to 'additional driver' under the application menu. Look for broadcom adapter then install.

Sluggish graphics:
Again, in some MacBook version, the NVDIA graphic card isn't appropriately configured out of the box. So go to 'additional driver' then try to install one of the listed NVDIA drivers. Some might not allow hibernate, some might not fix the sluggish-ness of your graphics, some might not do both, but some might fix everything! Try one that works for you. If nothing works, try going to NVDIA official site and download their latest driver.


Keyboard shortcut brightness doesn't work:
This one is pretty irritating, but I found the solution to be quite simple.
Edit the text file /etc/X11/xorg.conf (need root access)
In the "Device" section, add up this line:

Option "RegistryDwords" "EnableBrightnessControl=1"

Now save the file, reboot your Ubuntu, and you're keyboard is good to go!

Trackpad "gets in the way" when typing:
Sometimes when you're typing, you accidentally touch the trackpad so the field where you're typing loses the focus. This is due to your hand accidentally touching the trackpad that's really sensitive. (From this I realized how great Apple drivers are!) 
To fix this, install "Pointing devices" from Ubuntu Software Center. Run this program like running ordinary application. There is a really cool tweak to your trackpad, "Detect Palm". Basically this detects the "accidental" touch that happens when you're typing. For me, after installing this, the trackpad doesn't really "get in the way" anymore. (sometimes they still do, but not that often)

Disabling trackpad via terminal
Okay if you don't want to go into all the hassle of downloading additional software just to enable/disable trackpad or any other input device, here is how you do it using terminal.
'xinput list' -> this gives the list of input devices available.
'xinput set-prop [id] "Device Enabled" [1/0] -> to disable/enable the input device.
Just in case you have your trackpad disabled and forget to bring mouse, hit ctrl+alt+t to open terminal and type in the magic keywords above to enable your trackpad. Or maybe aliasing is better!

Okay so those are the tips so far. I'll be updating this if I found new fancy tricks. So far I'm loving my new Ubuntu 11.10!

Have fun with your Ubuntu!