Ryan Rampersad
Thoughts, opinions, ideas and now links
  • About
  • Podcast
  • Links

Yearly Archives

Year In Review – 2011 Top Posts

It’s been a long and busy year. I have tried to keep the good stuff coming down the pipeline for the few readers I have. Among other things, I wanted to drive up commentary from users but that goal was not achieved this year. So I’ll shoot for that in the upcoming year, and maybe some Nexus-magic will help with that.

I covered a few topics this year closely: the rise of the Optimus V and the disappointment of the Triumph. My traffic spiked due to these two phones coming out of the depths of Virgin Mobile. Of course, there was other important content too that found high marks. So, here we begin the top posts (via traffic) from 2011!

LG Optimus V Review

This review set me apart for a couple of weeks. CNet and other major news sites attempted to write reviews but it always seems that those are washed out and are not typical. Nobody reading blogs is average so why average your own postings? Anyway, the post described many details of the new phone and why I liked it. I compared to the Intercept, that horrible excuse for a phone, the iPhone and the iPod touch. If I wrote a year-later review though, things would be different.

Java – Failed to download required installation files

Nothing is more annoying to me than restarting Windows, you know, trying to get work done, then a couple of minutes later you’re doing something important and the Java updater comes up to complain that Java 6 Update 34 is available. Why can’t it be like Chrome? Update silently, in the background, and maybe let me know something changed when I launch it again in a couple of months.

Remind me again, why do I have Java installed? Crickets.

Dust Under Screen – LG Optimus V

Since this is the third highest ranked post of the year, I gather that this was a huge problem for a lot of people. Radio Shack was enough to accept the phone back when I told them it had dust under the screen, but get this – I had to pay for the phone twice. When I bought the Optimus back in February, it was priced via Virgin Mobile at $149.99 and Radio Shack had the same price. When I went back to return the phone due to dust under my Radio Shack warranty-plan, the price had gone up to $199.99 via Virgin Mobile (possibly to do popularity or constraints). Radio Shack’s deal is to give you back a gift card for the value you payed them originally, so that was about $165 (149+tax), but since the phone had gone up, I had to pay another $79 anyway to get the phone again ($199+warranty plan+tax).

PHP 5.3 – Not on 1and1 Yet

I wanted to make a Symfony 2 driven CMS but I couldn’t. Why? Because 1and1 fails to support the current stable version of PHP 5. PHP 5.2 has been out of favor by PHP.net for at least a year and there is still no progress. Since it’s so popular, I suspect many people want a solution to this problem.

Someone needs to make a GetPHPUpdated.org or something. That way, we can make a huge petition to get PHP on 1and1 updated, finally.

Virgin Mobile May Get the LG Optimus Black

Once you get an Optimus V, you love it to death. Once you have it for a few months and use it consistently, you realize it does not scale well. The Triumph was a good phone on paper, but the build quality and the horror stories drive the masses away from it. There is still hope, that the Optimus Black may come to Virgin Mobile as a secondary top-tier phone to sit alongside the Triumph. Look at how many of us have that hope. Please, Virgin Mobile, please, give us a phone that does not suck.

PHP 5.3.99-dev on 1and1

I haven’t looked into this since I found it in summer, but it was odd to me that there was some PHP 5.3 stuff lurking around on 1and1′s servers. Through a toggle in the administration panel, you could easily make something appear. I think since then, the version has changed to PHP 5.4-dev, but again, it means nothing. I think this means the people want PHP 5.3 if there are two entries in this list.

Check MacBook Air SSD Model

There is nothing like paying $1500 and going home only to find out your new MacBook Air is 20% slower than it could be if you had been lucky. The SSDs used in the 2011 Summer MBA models varied, some slow, some fast. This post was an appeal to just find the answer, instead of having to watch a four minute long video. How about 40-words instead?

Where is 2-Finger Swiping in Finder & OSX Lion?

So, where is it Apple? Myself and many others want to know. In Safari, the standard for navigating back and forth between webpages is intuitive and easy, just a two finger swipe left or right. In Chrome, for months now, the same has been true. In the Mac App Store, there are back and forward buttons, but the functionality is missing. In the Finder too, the buttons are present but the functionality precedent is not there. So much for consistency.

Lion Gestures in Chrome 14

In makes sense that when people were looking for other Lion gestures, they’d want some in Chrome too. Chrome’s implementation is interesting, since it does not provide previews. It just uses an arrow that gradually fades in from transparent to completely solid.

Fatal error: Out of Memory – WordPress Update

Can I ask you a question? Have you ever been out of memory? Has the memory ever been out of you? Well, if so, disable your plugins. WordPress is often installed on shared hosts with severe memory limitations. That causes a lot of problems when upgrading to a new version. Or it used to when WordPress would download all new files regardless of what has changed. Since it has a manifest, it can simply updated the changed files.

This year has been great, and there has been many wonderful posts. I hope this next semester brings out as much content as this fall, but as it usually goes, I go quiet from some point forward until summer when I am off on vacation yet again.

Have a good one.

Podcast 007 – Pepperoni Facing Right Side Up

It’s Christmas Eve! Or Adam, as some might say. This week’s podcast was well crafted and a great journey into the land of technology. Before our normal stories, we talked about my grandmother’s Christmas present, a portal into the Internet’s movie house, Netflix, through the infamously minuscule Apple TV. Then we delve into the rumor rabbit hole of the iPad 3. The show open is full of Google goodies and there’s even a jolly Jobs later on. All that and more, coming up on this Christmas Eve episode.

  • AT&T kills T-Mobile merger plans, will pay Deutsche Telekom $4b breakup fee
  • Deutsche Telekom could be forced into arms of Sprint
  • T-Mobile to get seven-year 3G roaming deal, 128 markets of AWS spectrum from AT&T
  • Samsung says TouchWiz keeps Galaxy S from Ice Cream Sandwich
  • OwnCloud
  • AMD Radeon HD 7970: 28nm Tahiti GPU Review
  • Disruptions: Wearing Your Computer on Your Sleeve
  • The web in 2011: HTML5 dominates Flash, trouble for data capped mobile surfers
  • http://www.youtube.com/watch?v=4t-SueJC8iI
  • Facebook is suing Mark Zuckerberg

You can listen to this wonderful episode right now for free, exclusively.

Listen to Pepperoni Facing Right Side Up

Help Needed: Custom Permalinks with Custom Post Types & Taxonomies

I’ve been attmepting to setup WordPress installation these past few days to manage the Friday night podcasts. The design was easy enough since I’ve done that before but my stumbling point has been these custom post types, custom taxonomies and the rewrite rules that govern them all.

Help Needed with CPT and Rewrites

Here’s what I setup: there is a custom post type (CPT) for episode. So for each episode of a podcast, I add a new Episode. Now, I figure there will be more podcasts on the same installation in the future, so I made a custom taxonomy (CT) for podcast. So when I make a new series, I just make a taxonomy entry and set the episode to have that taxonomy. So that’s good so far.

My ideal URL permalink structure would be this: the-nexus.tv/{podcast-name}/{episode-name}/ where the {podcast-name} is the name of the podcast, like “On The Hill” and the episode-name is the post-name of the episode. An example of this would be: the-nexus.tv/on-the-hill/243/. Does that make sense?

Right now, episodes have permalinks like so: the-nexus.tv/episode/1/. This is instantly problematic: the /1/ name is taken up forever across all episodes and there is no mention of which podcast this episode belongs too. What I need is the name of the podcast to be apart of the episode slug so that multiple episodes can have the same post-name. Somehow, this does not sound entirely possible.

What have I tried? I attempted to follow Jonathan’s post about permalinks and post types, but I did not have much success with it. I have searched the WordPress forums. And Google.

So, I’m really not having any luck. I read a mailing list entry from Otto that explains that custom post types don’t really function within the rewrites of normal posts, but that didn’t make too much sense to me.

Any ideas?

Tabs to Spaces in NotePad++

I frequently use TextWrangler on my MacBook Air to do some quick coding. One of the problems I have encountered is that when I switch back to Notepad++ on Windows, my spaces become tabs. I’ve set TextWrangler to use spaces instead of tabs and I wanted to mirror the same settings in Notepad++.

Notepad++ Tab Settings

To change the tabs setting go to: Settings > Preferences > Language Menu/Tab Settings. Then on the right, you can set a global default for tabs or spaces, and the number of spaces per tab. You can additionally specify customized tabs/spaces settings for each language supported with the menu above.

Once again, happy tabbing.

With Notepad++ 5.8.7.

Podcast 006 – Toner Disaster

On Friday night, we had a little bit of toner trouble. Matthew Petschl could not join me tonight to cover this week’s tech news but that’s fine, I did it anyway, but this time with proper volume and more toner. It’s been a busy week for both of us with finals, so we were a little slow to gather the news, so I just picked some relatively random stories from the short time I had in between studying. Additionally, you must experience the toner disaster.

In the news this week:

  • Amazon’s Kindle Fire lets kids charge up a storm
  • Kindle Fire software update coming in less than two weeks, performance and UI improvements promised
  • Amazon Kindle Fire redirects all Android Market requests to Amazon App Store
  • Apple may launch new MacBook Pro with 2880 by 1800 display resolution, say sources
  • Summer 2011 MacBook Air 11-inch & 13-inch Pixel Densities
  • Verizon ‘Very Serious’ About Making Bid for Netflix, Banker Says

In the lame lightening round, I also mention:

  • AdBlock Plus to let ‘acceptable ads’ through to users by default
  • HP to Contribute webOS to Open Source
  • Free Calling Within Us and Canada

It wasn’t fantastic, but it was a good episode. You should listen to this week’s episode right now, for free, exclusively.

Listen to Podcast 006 now!

Browser Shortcuts Everyone Should Know

My dad and I were in the living room recently and he was using our TV computer.

While using Chrome, he kept mouse over to each little circular x to close each tab. I suggested he try a different shortcut. If you’re using a mouse with a scroll wheel, you can press the scroll wheel to close a tab. Just hover over a tab and click the middle-button and away the tab will go. He liked that since it’s tricky to be precise on the screen with the mouse when you’re ten feet away.

A little later, he accidentally closed a tab he wanted to get back. He was about to retrace his steps through a bunch of links but I suggested a different shortcut. Control + Shift + T will reopen the last tab closed, and continue to go through historically closed tabs too. He really liked that little trick.

Finally, he was typing an email up. Somehow, he got to the word “monotny” but it was underlined so he knew it was wrong (because that’s what Word does when words are wrong). I told him if he right clicks the underlined word in Chrome, it will bring up spelling suggestions from Chrome’s dictionary. I warned him that it’s not same dictionary as the one Google uses to fix keywords when searching. Instead of copy and pasting into a new tab, there was a better way. Like right clicking for built-in word corrections, he could look down the list for ‘Search Google for “monotny”‘. He thought that was pretty helpful too.

In short, my dad learned a lot today while sitting in the living room around the TV computer. That’s pretty good for a rainy day, isn’t it?

C: undefined reference to `pow’

I was helping a friend with a little C-program recently. C is not my language of choice, and when I was tinkering years ago, I was using a Windows compiler and not gcc. Things are a little different in the Ubuntu compilation world. I was receiving an unexpected error message even though I had proper headers.

testing.c:(.text+0×156): undefined reference to `pow’
testing.c:(.text+0×174): undefined reference to `pow’
testing.c:(.text+0x18e): undefined reference to `pow’

#include <stdio.h>
#include <stdlib.h>
#include <math.h> 
#include <time.h>

My code was modestly simple. The variables were previously defined and perfectly in order.

      double left = a * pow(b, 3);
      double right = pow(c, 2) - pow(d, e);

Apparently, in order to make gcc load the proper library, you need to explicitly tell it to in the call to compilation. gcc -lm testing.c -o math && ./testing

Notice the -lm flag? That tells gcc to load a specific library, and in this case, the math library.

Podcast 005 – Jumping Around In Order

Last week, we had some trouble making an adequate recording. This week? Well, Matthew Petschl and I think it’s good enough to publish this week. Sadly, my levels are a little low, so if you don’t actually like listening to me, you won’t have to! We need labs coats in order to conduct a scientific park trolling experiment.

This week, we tried to trim the news down a little. At the very least, there was actually news this week, unlike last week which was pretty stagnant.

  • Apple Considering Building Huge New Data Center in Oregon
  • AT&T vows to keep pursuing T-Mobile merger
  • Apple job openings hinting at Siri API, prettier interface and additional languages
  • New No. 2 in Browser Battle
  • AMD Realizes That Bulldozer Has 800 Million LESS Transistors Than It Thought!
  • Games take largest share of Android’s first 10bn downloads

And we even did a new lightening round, where we offer no commentary on the headlines to just get the stories out there.

  • HP Is Reviving The $99 TouchPad Firesale! Refurb Models To Hit HP’s Ebay Store On 12/11
  • Facebook To Launch A Subscribe Button For Websites
  • ‘Steve Jobs’ Becomes Amazon’s Best-Selling Book of 2011
  • Bill Gates May Build Small Nuclear Reactor

You can listen to this week’s episode, right now, for free, exclusively.
(more…)

Save curl output to bash variable

Saving the contents of a bash curl call is pretty easy.

Variables in bash work something like this.

variable='hi'

Capturing input is relatively easy too.

variable=$(ls -la)

If you echo’d out the contents of variable, you’d print out whatever was in the directory when you ran the command.

So if you put the two together along with curl, you get the answer.

variable=$(curl http://ifupdown.com/apache/logs/log-2011-08-11.log)

Now, if you echo’d out the contents of variable again, you’ll see a gigantic log file! No, not really, but obviously you’ll see the contents of whatever file you want to curl.

Happy curling

Scheme: get-nearest+

Logic often requires you to find the lowest or highest value in an array. That’s easy just about everywhere. Sometimes though, you need to get the nearest number, and that can be a slight challenge, espeically in Scheme.

I wrote a little procedure called get-nearest+ that given a value, it will attempt to find the next largest value in that array. For example, given 24 and array of 10, 9, 35, 2, 29, 44, this procedure will return 29, because 29 comes right after 24.

I needed this logic in Scheme, but it’s easy enough to translate into C-based language too.

(define (get-nearest+ value lst)
  (define ordered-lst (sort lst <))
  (define (swap-value current found)
    (if (> current found) current found))
  (define (swap-indicator current found)
    (if (> current found) #t #f))
  (define (iterate fragment found break)
    (if (or (null? fragment) break)
      (if break
        found
        (car lst)
      )
      (iterate
        (cdr fragment)
        (swap-value (car fragment) found)
        (swap-indicator (car fragment) found)
      )
    )
  )
  (iterate ordered-lst value #f)
)

The magic of this is the early return. By setting break to true at the same time as setting the new element in found, we return early and even larger elements are not returned.

Update

In my initial testing, I used this example given 24 and array of 10, 9, 35, 2, 29, 44. The problem with this is that if 25 comes after the 29, it would not be picked up. The early return sees to that. To remedy this, I use a sort-function to order everything. In this way, 25 will always come before 29 does.

Python: TypeError: can only concatenate list (not “NoneType”) to list

It is pretty unusual for me to be coding in python, but I’m just following the course in my computer science class. I was coding a recursive list generator, essentially making a list with a given start and ending value of even numbers between them in the list.

In my interpreter, I received the following error.

return [start] + list_even(start + 1, end)
TypeError: can only concatenate list
(not "NoneType") to list

I don’t really know the nature of Python error messages yet, but I think this means that I’m attempting to something that isn’t listable (e.g. able to be put into a list). So, something that cannot be added to a list.

My code is pretty simple, though in real life I would never do this recursively.

def list_even(start, end):
  if start > end:
    return []
  elif start % 2 == 0:
    return [start] + list_even(start + 1, end)
  else:
    list_even(start + 1, end)

Everything looks in order. We have our definition, our if-statement, an else-if branch and a concluding else. Each of those cases have an return. Oh, wait. They don’t! Notice the else branch does not return a value, instead it just calls itself without returning. That’s the problem!

So, in short, I missed a return so a NoneType (e.g. null value) was returned during the previous call and it tried to append it on to the list. And clearly appending a null onto a list won’t work, only appending lists to lists works.

Correct Change in Java

When I was a freshmen in high school, one our earliest programs was to find the correct change for some number of cents. I remember when I wrote that first program, I did it an atypical way and got some strange looks. Instead of using nested modulus like everyone else, I used integer division and then subtracted out the difference from a running total.

Years later, I thought it would be cool to redo that program and it certainly was fun. I used the same methodology in fact, but with a couple of optimizations.

I start the program off by creating a Scanner object for user input and a prompt.

Scanner scanner = new Scanner(System.in);
System.out.println("Enter some amount in cents: ");
int cents = scanner.nextInt();

Then the optimizations kick in. There is a denominations array, which has a list of coin values, from 1 dollar, a quarter, a dime, a nickel and finally a penny.

int[] denominations = { 100, 25, 10, 5, 1 };

One of the original requirements of the program was that the amount of coins needed must be in their proper plurality. I can do this easily by having a two dimensional array of strings that store both forms of each word. You might ask, why not just attach an extra s to the end if it’s plural? Well, penny doesn’t turn into pennys.

String[][] terms = { { "dollar", "dollars" },
        { "quarter", "quarters" }, { "dime", "dimes" },
        { "nickle", "nickles" }, { "penny", "pennies" } };

The program will spit out values for each of the denominations listed, so it will contains dollars, quarters and so on and it’s store in this values array.

int[] values = new int[denominations.length];

I use a rolling total to keep track of how much change is left over still.

int rolling = cents;

The magic happens in the for-loop. It’s completely standard, initialized to 0, counting towards the length of the denominations array and incrementing by 1.

for (int i = 0; i < denominations.length; i++) {

The calculations happen in the next section. Basically, the denomination integer pulls the proper value from the denominations array. Then, the value in the values array is set to the integer division of the rolling total and current denomination. Finally, the rolling value is truncated by the denomination by modulus.

    int denomination = denominations[i];
    values[i] = (rolling / denomination);
    rolling = rolling % denomination;

To pick the proper singular or plural, the value is checked against being 1. Keep in mind that values of fractions are indeed plural. You have .1 dollars, e.g. ten cents, or a dime.

    String term = (values[i] == 1 ? terms[i][0] : terms[i][1]);

Finally, there is the printing logic which always gets in the way. I certainly wish there was a better way, but this was the best I found. Basically, by counting up until the last value, I print without a new line the value and then the matching proper term, and when it reaches the last value, I print an and, value, term and finally a period.

    if (i < (denominations.length - 1)) {
        System.out.print(values[i] + " " + term + " ");
    } else {
        System.out.println("and " + values[i] + " " + term);
    }

Here’s a short sample run with different amounts of cents.

Ryans-MacBook-Air:APCS3 ryanrampersad$ java CorrectChange
Enter some amount in cents: 
119
Your change is: 1 dollar 0 quarters 1 dime 1 nickle and 4 pennies.
Ryans-MacBook-Air:APCS3 ryanrampersad$ java CorrectChange
Enter some amount in cents: 
169
Your change is: 1 dollar 2 quarters 1 dime 1 nickle and 4 pennies.
Ryans-MacBook-Air:APCS3 ryanrampersad$ 

I remember when I wrote this program four years ago. This program is 35 lives with a bunch of whitespace. My code from youth was probably more like 70 lines. As you code, you mature. As you read others’ code, you mature too. Experimenting is the best way to grow. You can of course download the full source code.

Happy counting.

Meta Refresh

Doing the classic meta refresh, even with today’s fancy server side and JavaScript tricks, is one of the most reliable and easy ways to transfer a user from one page to another across all browsers. In fact, I used it just today when I needed to redirect users to a special Internet Explorer 6 version of a particular page.

    <meta http-equiv="refresh" content="5; url=home/classic/" />

The URL should obviously be set to the location that you want to user to be redirected to.

As I mentioned needing to redirect Internet Explorer 6 users, I can wrap them in Internet Explorer conditional comments to redirect those visitors only.

<!--[if IE 6}>
    <meta http-equiv="refresh" content="5; url=home/classic/" />
<![endif]-->

Happy refreshing.

Podcast 003 – Double Sided Sticky Staples

Thanksgiving treated us well. Maybe a little too well. On Friday evening, painting extraordinare Matthew Petschl and I recorded our third episode! This episode is full of unconscious rambling, confusion and hilarity. Actually, we tried to do things a little differently this time around. We created some stable intro-music and we began with a great open. It wasn’t planned. In fact, this episode is the fruit of absolutely no planning. All of those toxic fumes and insane shoppers really made us tired this week, so if we’re a little off, don’t worry about it too much.

The topics we covered were pretty interesting, but in all honesty, our banter is far more amusing than any news from this slow news week.

  • NETFLIX: Oh, And By The Way, We’re Going To Lose Money Next Year
  • AMD’s Bulldozer server benchmarks are here, and they’re a catastrophe
  • The Facebook Phone: It’s Finally Real and Its Name Is Buffy
  • Citing “Security Concerns” Penguin Pulls New Titles from OverDrive
  • Reported Retina Display iPad 3 with J2 codename shows up in hidden iOS 5 code
  • Disk drive prices swell 5% every DAY in floods aftermath

Matthew would also like to introduce his new favorite segment! The Q&A segment. We want you to ask us questions in the comments below so we can talk about them on the air. We’re not really equipped for live questions, so for now, these modular delayed action comments will have to suffice.

So, listen to this week’s episode now!

(more…)

Mac Terminal – Say D D D D D Droid

Many months ago before the end of high school as I knew it, my friend that had a Mac was showing me how he could make the terminal play the droid sounding android voice. I looked it up today to hardly find a trace of it on the Internet as far as my keywords would take me, except my own post about it included in among other twitter chronicles.

D D D D Droid in the Mac Terminal

Music to my ears ~

Enter this in the Mac terminal.app:

say -v cello d d d d d d d d d d d d d d d d d d d d d d d d d d droid

D R O I D

Next>

© 2013 Ryan Rampersad.