Skip to content

existence, refactored

With kindness comes naïveté. Courage becomes foolhardiness. And dedication has no reward.

Archive

Category: Training

I’ve been doing some programming screencasts lately over my Youtube channel. They’re not really “screencasts” ala RailsCasts but more like informal streamed videos that you’d see in Justin.tv/Twitch.tv.

These screencasts were recorded in 720p so it’s a good idea to select a higher resolution then view the videos in full screen or the large player in order for you to read the code properly.

Here I code a hexagonal “game of life”-like cellular automata. Used Ruby, Gosu, and RSpec.

Walking through coding a simple Rails app. Bunch of technologies discussed like Twitter Bootstrap, Heroku, and git.

Going through Project Euler problems via brute force using Java.

WordPress Installed

Here’s a quick update to this mini-tutorial. Previous parts can be found here and here.

Installing MySQL

Installing MySQL is so simple that I don’t need to hide it behind the cut. The one in the Ubuntu repositories work just fine:

$ sudo apt-get install mysql-server-5.1

Note that you will be asked to enter a root password somewhere in the installation.

To wrap up the installation run

$ sudo mysql_install_db

to initialize the installed server and

$ sudo mysql_secure_installation

to secure it.

In mysql_secure_installation, you’ll be asked for your root password and then you’ll asked if you want to change it. Just enter “n” since there’s no reason to change it this early. Then you’ll be asked if you want to do some things to secure the database which is, of course, what we want to do so just hit Enter for each question to choose the default answer (“Y”).

continue reading…

phpinfo()

Here’s the next part of my basic web server administration tutorial.

At the first part, we set up the virtual machine. Now we’ll be setting up the web server itself.

Set Static IP Address and fake Domain Name

Before we could proceed with installing our web server, let’s do a couple of things to make our server behave more like a “normal” server.

First is to set our server’s IP address to a static IP address. There are a bunch of ways to do this (e.g. change the router settings), but we’ll just go with changing our server’s settings

Running ifconfig and route will give us the current IP address and gateway.

ifconfig and route

In this case, the new IP address is 192.168.1.125 and the gateway is 192.168.1.5. We can now apply these settings to /etc/network/interfaces. Open the said file via:

$ sudo vim /etc/network/interfaces

(For this tutorial, I’ll be using vim as the default text editor. If you find vim too daunting, you can replace all instances of vim with nano)

It will look something like:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

Now replace the last line with the following:

iface eth0 inet static
address [address here]
netmask 255.255.255.0
gateway [gateway here]

for example:

iface eth0 inet static
address 192.168.1.125
netmask 255.255.255.0
gateway 192.168.1.5

To make sure you got the static IP settings correctly, you can restart the server via

$ sudo shutdown -r now

or you could just simply restart the network interface:

$ sudo /etc/init.d/networking restart

Here we see the /etc/init.d folder where the init scripts (like networking) are placed. Aside from being executed automatically upon boot to start services, they can also be used to stop or restart the said services just like what we just did with networking. We will see more of /etc/init.d/ later in this tutorial.

Now that we’ve set the IP address as static, it’s time to set a fake domain name.

Normally, when you’ve got a server with a static IP address, you’d have to go and buy a domain name from a registrar like Namecheap and you’d go through the steps in linking that name with the IP address and waiting for the DNS propagation.

For this tutorial, we’re going to skip all that by faking it with the hosts file.

First let’s update the server’s /etc/hosts file to add our fake domain name “mysite.dev”:

sudo vim /etc/hosts

Add the line at the end:

192.168.1.125   mysite.dev

You can verify the new setting by using the ping command.

user@ubuntu:~$ ping -c 4 mysite.dev
PING mysite.dev (192.168.1.125) 56(84) bytes of data.
64 bytes from mysite.dev (192.168.1.125): icmp_seq=1 ttl=64 time=0.172 ms
64 bytes from mysite.dev (192.168.1.125): icmp_seq=2 ttl=64 time=2.38 ms
64 bytes from mysite.dev (192.168.1.125): icmp_seq=3 ttl=64 time=3.34 ms
64 bytes from mysite.dev (192.168.1.125): icmp_seq=4 ttl=64 time=1.59 ms

--- mysite.dev ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3016ms
rtt min/avg/max/mdev = 0.172/1.874/3.342/1.161 ms
user@ubuntu:~$

Now let’s apply the fake domain name mapping to the host Windows computer. Like in Linux, the hosts file in Windows requires admin privileges so we first need to run the text editor as Administrator in order to allow us to modify it.

Run as administrator

Right-click Notepad and select “Run as administrator”. Once open, you can now add the “192.168.1.125 mysite.dev” to the end of the C:\Windows\System32\drivers\etc\hosts file.

Now you could change the PuTTy settings to use “mysite.dev” instead of the actual IP address.

The actual installation of the web server below the cut.

continue reading…

So after spending the entire day walking around doing stuff (and at one point get wrangled into MCing) for DevCon at DevOpsDays, me and a couple PhRUG guys got on a (red-eye?) bus to Baguio City for the non-official Philippine leg of the Global Day of Code Retreat.

This isn’t a full write-up of the event so I’ll keep this short and simple. The event was at Drei‘s place with just a bunch of Ruby, Python, and PHP guys from both Manila and Baguio hacking up random stuff instead of doing the whole Code Retreat thing.

after event

at the after event, aka “Yo dawg, I heard you like taking pictures so here’s a picture of people taking your picture so you can have a picture of you taking pictures of people taking pictures”

Being the slacker that I am, I didn’t have anything planned out beforehand. I thought I’d just go the same route as with Startup Weekend Manila and just be a rubber duck floating around groups. Fortunately, Buddy brought along his significant other Rizza with the intention of having her learn programming from the participants of the event.

I couldn’t resist this teaching challenge. So for the entire event, I went on to give an impromptu crash course on the fundamentals of software development.

I started off with basic imperative/procedural programming via pseudocode (to drill in the idea that software development is not about computers but about solving problems). As we progressed I moved on to Ruby for the more technical side of things (basic data types) up to Object Oriented basics.

first lesson

first programs – potato salad and quadratic formula

By mid-day, I had this little flash of insanity and began downloading >250MB of development stuff from a certain site.

That flash of insanity was to go back to the original Code Retreat exercise, Conway’s Game of Life, and build it in Java to teach software development: coding conventions, revision control, test automation, refactoring, etc.

Of course, I had to teach the most crucial concept in software development: how to wing it. And that was where Android came in.

So we had a base GoL class and a freshly installed Android SDK. A couple of Google searches later and a lot of guesswork, we were able to make the whole thing work as a Live Wallpaper in around 1.5 hours.

screenshot of wallpaper

Lack of sleep and preparation can turn a Ruby guy into a Java developer. LOL

..or podcast, whatever you want to call it.

So I’m gonna be recording rants for the next few weeks to figure out and fix my vocal problems. I’m ok with topic suggestions but I’m not really expecting any.

Will be posting the recordings on this site until I get to setup another page for the recordings (probably a wiki).

Episode 0 – Intro

Episode 1 – Pizza (pt1 of 2)

Episode 2 – Pizza (pt2 of 2)

UPDATE

Podcasts now posted daily at http://bry-rants.tumblr.com/

Last talk for the year (barring a possible surprise talk at Code Retreat): a talk about current trends in web technologies at DevCon UPHSD. This time it’s a 20 minute talk that I had to drag out to 40+ minutes to cover for the missing speakers. Good thing I wasn’t pressured to deliver it in English.

So yeah, we had 2 missing speakers, leaving Alvin and I to handle everything.

But surprisingly, this DevCon event was far better than the one in DLSU (read: a more prestigious university) mainly because the students were really interested in what the two of us have to say. Sure, our talks may have been boring for most of the audience, but by the time we left the campus, we’ve fielded over a dozen questions, mostly from students who approached us after the event ended.

In comparison, AFAIK, only one student asked a question in DLSU.

Pride? Apathy? I really don’t know.

Anyway, here’s my talk and the slides.

Did a lightning talk for DevCon DLSU last Wednesday. Not really liking the end result. My decision to deliver it in English is mainly to blame: I wrongly guessed that La Salle students would react better to English than Tagalog (the latter I prefer when giving talks), and all I got from it was having my lack of practice look more obvious.

I think the worst part about my talk was the way how the “sarcastic-whiny-tone” I use in my normal everyday Tagalog creeped into my usually more professional sounding English voice. I’ll probably have to do weeks of voice retraining to eliminate that. =/

Anyway, here is the video of the talk as well as the slides.

antialiasing

I frequently make slides but since I don’t like paying for Office/iWork and I haven’t drunk the Google Docs kool-aid yet, my tool of choice for presentations is LibreOffice Impress.

LibreOffice is more than sufficient for my needs. There are, however, two major problems I’ve encountered so far:

  1. ODP format isn’t fully supported by SlideShare, as you could see from my Haml presentation last year.
  2. I sometimes present in Windows (e.g. Rails workshops with everyone in the audience using Windows) and I’ve noticed that anti-aliasing sucks in that OS even in 3.4.3rc. With me having very good eyesight combined with most of the text in my slides being large phrases (i.e. the proper way to build slides), those jagged edges can be annoying.

Fortunately, there’s a simple solution to both of these problems:

Export to PDF

By exporting to PDF, you bundle the correct fonts in the document. Also, this approach leaves the anti-aliasing to your PDF reader which is more likely to have better AA rendering.

The picture at the top of this post shows the difference between LibreOffice and PDF-XChange Viewer‘s AA rendering, respectively.

Computer Science teachers have it easy. Every time a new semester rolls in, they can simply reuse the material they’ve been using for years.

As a teacher of a quickly evolving web framework, I do not have that luxury.

As I write this, less than 24 hours have passed since the Rails Core team released the new version of Ruby on Rails: version 3.1.0. This means that I now have to update my student manual (i.e. this document) for upcoming classes to use this new version. Having done that before when we moved from Rails 2.3. to Rails 3.0, I know how much of this document will be changed: sections will be gutted, swaths of code rewritten, and at least one new chapter would be added.

And, yet again, I will not be paid a single cent for those updates.

So instead of just letting this nearly obsolete document go to waste, I’ve decided to give it away for free.

Get it here.

Just a quick write-up of my Pecha Kucha talk for RedDotRubyConference last night.

Full “script” below the cut. If you’ve been there in my talk, I ad-libbed a lot more this time around than when I did my Ignite talk.

continue reading…