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

Archives

Kindle: A Reasonable Price

Just a week ago, I wrote about my problem with Kindle books – the lack of the redistributable property. Essentially, books were often priced too high by publishers to make buying digital Kindle copies a worthwhile practice. My example was $9.99 for a Kindle copy you cannot give away or $13.99 paperback copy you can give to your friend for free.

I’m not giving up on Amazon or Kindle books yet. I was browsing through my favorite, the fiction section. I found two books. One was published by Random House and the other has no denotation and it makes me assume it was published on Kindle and via some form of physical Amazon self-publishing.

Expensive Amazon Kindle Books - Like watching and owning a movie

(more…)

PHP 5.3.99-dev on 1and1

A few days after wondering where PHP 5.3 support was on 1and1, I found this little gem in the 1and1 FAQ: PHP 6 support. The full document explains that you can but shouldn’t enable PHP 6 because it’s in developmental stages. When I throw an .htaccess file with the PHP6-ify directive, AddType x-mapp-php6 .php, in the same folder as a phpinfo call, I get a lovely little message:

PHP Version 5.3.99-dev

So, maybe we have something here.

PHP 6 Development - PHP 5.3.99-dev

I have yet to check if this really enables PHP 5.3 support or if just does something funky with the version numbers. I tested the .htaccess PHP-6 enabled directory with a little test script from the PHP 5.3 anonymous functions page.

// from http://php.net/manual/en/functions.anonymous.php #example-1
echo preg_replace_callback('~-([a-z])~', function ($match) {
    return strtoupper($match[1]);
}, 'hello-world');
// outputs helloWorld


// from http://php.net/manual/en/functions.anonymous.php #example-2
$greet = function($name)
{
    printf("Hello %s\r\n", $name);
};

$greet('World');
$greet('PHP');
// Hello World Hello PHP

When I test this without the special .htaccess, it spews a PHP 5.2 error, a function is in the wrong place.

Parse error: syntax error, unexpected T_FUNCTION in /homepages/27/d199890134/htdocs/dev/test.php on line 4

With the directive, I get lovely results with no errors. So perhaps you’ll want to try this out.

helloWorldHello World Hello PHP

It looks like we just found PHP 5.3, albeit in a round-about way. Again, I’m not 100% sure that this is true PHP 5.3 support and it could be that it is an untuned and sloppy trunk build that has loads of bugs and whatnot.

If this works for you, leave a comment. I’m going to guess it won’t universally work through different packages.

August 8th, 2011

Some of the commenters tried this method and for some time they did find a PHP 5.3 level of functionality. Recently though they have been finding PHP 5.4alpha1. I would not recommend this for production as it apparently changes all the time.

IP address from hostname – Ubuntu Lucid

If you have an IP address but you don’t have a hostname to go along with it, you can easily get it via Ubuntu’s host command.

For instance, I have an IP, 97.115.69.11, and I needed the hostname. To get it, I simply ran host 97.115.69.11.

ryan@ryan-desktop:~$ host 97.115.69.11
11.69.115.97.in-addr.arpa domain name pointer 97-115-69-11.mpls.qwest.net.

Happy IP-grabbing.

Theme Updates

A couple days ago I began using the WordPress 3.2 release candidate. I was impressed by the back-end overhaul and the interface streamlining. So much so that I wanted to update yet again my own theme.

The theme is powered at its core by Hybrid. I call it Ryan’s Hybrid Theme because an original name was just so unoriginal. The initial release went live on May 2nd, and 50 days later, here we are with another update.

Summer - Theme Updates

(more…)

WordPress 3.2: Post UI

I am testing the upcoming release of WordPress 3.2 and there a few big differences in the Post UI that are quite welcome. Some pictures will be best to demonstrate the biggest differences.

The old Post UI can be described as dark due to the gray background and inspired in part by classical print traditions. With WordPress 3.0 and following the trends of the day, rounded corners were all the rage.

WordPress 3.1.3 Post UI

WordPress 3.1.3 Post UI - Current State


(more…)

PHP 5.3 – Not on 1and1 Yet

Update: January 2013

I was sent an email a few weeks ago that notified me of impending changes on my server. PHP will be upgraded from 5.2.x to 5.4.x. That version jump will include all features of PHP 5.3 of course.

Update: June 2011

Maybe there is PHP 5.3 support on 1and1.

I wanted to use a certain wonderful PHP 5.3 framework for an upcoming project. I needed the official word on the state of PHP 5.3 on my beloved host, 1and1. I sent off an email to technical customer support.

Here’s the email I sent off this morning.

Hey there. I was wondering if it was possible to enable PHP 5.3 on 1and1 shared hosting servers? PHP 5.3 has been recommended since July 2010 and as it is a year later, 1and1 servers should be able to use it.

I checked my control panel and I can toggle the global PHP version to PHP 4, PHP 5 and something called PHP dev, but it is not particularly clear if PHP dev is PHP 5.3. I set my global version to PHP dev but my phpinfo() function still returns 5.2.17.

It would be really fantastic if I had access to PHP 5.3 because I may have to consider alternative hosting accommodations otherwise.

Thank you and have a good one.

–
Contract ID: xxxxxx; Customer ID: xxxxxx
–
Ryan Rampersad
www.ryanrampersad.com

Since it was Sunday, I didn’t expect a reply so soon. But here it is in its full unedited glory.

Dear Customer,

Thank you for contacting us.

As we had double check further, as of this moment, we only run php version 5.2.17. Our system administrator as still on the process of upgrading of php version to php 5.3 version.

If you have any further questions please do not hesitate to contact us.

–
Sincerely,
xxxxxxx xxxxxxxxx
Technical Support
1&1 Internet

Well, that’s definitive, isn’t it? They had to double check, but the system admininstrator is still slowly typing out that apt-get command to update to the latest version of PHP. But really, can I expect more from 1and1? With my blog slowly creeping up to the memory limitations and quite probably the daytime-peak connection traffic, I might be tempted to change. Or not.

So, please 1and1, get on this because I really need PHP 5.3!

Readers: if you have 1and1 as a host and found this page via Google or some other search engine, please leave a comment. It spreads the awareness.

Keynote with Dad

I was watching the two week old WWDC Keynote with my Dad on father’s day. He likes it when I share the latest tech-news with him. Since I was busy these last two weeks, I wasn’t really able to with graduation and orientation. Tonight, we took the time to run down the Keynote peppered with my tech-news monger tidbits. It was a lot of fun.

Odd Categories

Funny thing. I blog about Ubuntu all the time but I don’t have a category for Ubuntu. No, I have a category for Linux. I don’t have a catch-all category for crappy-closed-source-operating-systems either. No, I have one for Windows.

Graduation Quiz

You know when you go to a movie theater and you get to your movie a little too early? You see some trivia question on the screen and then thirty seconds later, they reveal the answer. I ran with that concept and created my own trivia game for my graduation party. I wrote a little JavaScript app that would automatically fetch questions, show some multiple choice and eventually reveal the answers. Everyone that came in through the front door almost immediately saw the quiz on the TV and began trying to figure out the answers.

Trivia on the TV

Trivia on the TV

(more…)

Kindle: Lack of Redistribution

For my eighteenth birthday last November, my parents bought me a fantastic wifi-Kindle. I had tested the Kindle for Computer service prior to getting the Kindle but I never successfully completed even a single book because the experience of reading a novel on a monitor sucks. I loved reading on the Kindle itself though. I’ve purchased maybe sixty books via Amazon Kindle and I really did read most of them. It was awesome. But I have a sticking point and I’ll get to it in a moment.

Amazon Kindle
(more…)

Apple Keynote Reflections

After cooling down for a week, it’s fitting to do a little reflection on what was revealed and what was not. I’m not going to go in-depth about any particular features and obviously this is not full coverage, everyone’s done a better job at that than I would.

OS 10.7

First revealed last October, it has changed very little from what we saw back then. There are a couple of half baked backed features. For example, Full screen apps? It’s incredibly revolutionary. No, I’ve talked about this before and it’s always bothered me that the dock would always be present on the screen and windows could not go below the dock. Another example is Launchpad. For some people, that will be better for people who can’t remember what apps they have on their system, but I think Spotlight really works wonders for users like me – that know what they are doing.

Lion - the biggest cat!

The latest version of OSX since (Snow) Leopard!


(more…)

Last Week Recap

Two Fridays ago on June 3rd, I experienced the last day of high school. Last Thursday on June 9th, I formally graduated. I have my graduation party on the 17th at my house. Tomorrow, June 13th, I will be attending a two-day orientation at the University of Minnesota where we learn about the campus and pick our classes.

I was taking what I like to call an Internet Vacation where I don’t really engage at all with the broader world out there. So that’s where I’ve been. That said, I was still participating the usual ravenous tech-news watching.

It all started with the Apple Keynote on OS 10.7, iOS 5 and iCloud. Then I watched the Sony and Microsoft briefing for the PS3, Move, and PSVita and Xbox 360, Halo and Kinect. On Tuesday, I was disappointed with the lackluster Nintendo announcement with their new HD Wii, the Wii U.

Wednesday was my last official day working for Saint Paul Public School Community Education this summer. Technically, I was never sent a new schedule and I could be working but at a different place. So we’ll just have to see how that turns out. The fall session usually has more classes than the summer session obviously because nobody wants to work or go to classes during these wonderful summer days.

The formal graduation ceremony was on Thursday. At Roy Wilkins Auditorium, 470 seniors successfully graduated with a grand attendance. I’m pretty sure I botched the moving of my tassel but I’d have to see the video recordings to verify. The graduation will be rebroadcast sometime in July. I’d like to get a true recording of it and hopefully get it online somewhere. We’ll see about that.

Directly after the graduation ceremony, the senior all night party was on. We had truck loads of food. First we had burritos, then pizza, then more pizza, then we had Jamba Juice and ice cream. In the gym, there were three inflatable games, there was of course the mandatory volleyball and basketball and finally the silent auction that had no worthwhile items. In the main hall, there were casino games, from black jack to poker, even roulette. In the side hall, there were arcade games, a couple of pool tables, a ping-pong table and of course the boring movie room. Finally, in the back, it all comes back to the food.

I slept through most of Friday afternoon and evening after getting to sleep around 8am. Since then, I was catching up on all the missed tech-news and other chores I’d been neglecting for the last week and a half. Of course, my vacation once again begins once I go off to university tomorrow, but only for two days.

That’s my weekly recap. Have a good one.

HashMap Iteration – Java

I needed to iterate a HashMap in Java. I can do it effortlessly in PHP with just a regular array or in JavaScript with an object literal. In Java though, the process is a little bit more obtuse.

I had a special case – needing both the key and the value at the same time. Let’s go with one or the other for right now. Let’s establish our map.

HashMap<String, String> map = new HashMap<String, String>();
map.add("Hello", "world");
map.add("Ryan", "rampersad");

That’s our example map. It doesn’t really matter what the contents are, but it’s example.

Now, let’s loop over the keys.

Iterator it = map.keySet().iterator();
while (it.hasNext()) System.out.println( it.next() );

This will print out Hello and Ryan. Those are the keys of the values in the Hash Map.

Now let’s loop over the values.

Iterator it = map.values().iterator();
while (it.hasNext()) System.out.println( it.next() );

This will print out world and rampersad. Those are the values.

Finally, the most interesting. To get the value and the key at the same time, a special Map Entry object can be made with an entry set.

Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
  Map.Entry<String, String> kv = it.next();
  System.out.println(kv.getKey() + "=" + kv.getValue());
}

This code prints Hello=world and Ryan=rampersad.
This is new. First, we call entrySet to get the special set of key-value pairs. Then in the loop itself we use a special Map.Entry object with parameters of String, String, because that’s how our map is made, and set it to it.next. That enables use to call for the key and the value.

I hate while loops so I suggest this format instead.

for (Map.Entry<String, String> kv: map.entrySet()) {
  System.out.println(kv.getKey() + "=" + kv.getValue());
}

The beauty of this is that there is no Map.Entry object being declared inside the actual loop, instead it’s made it its header. All the cleaner.

Getting a key-value pair from a HashMap, the point of HashMap, I think, is slightly convoluted but nothing hard.

Happy mapping.

How to Disinfect a Computer

This weekend, I helped my dad disinfect one of his friend’s computers. He claims he did not install a fake anti-virus program, but there it was haunting the computer. It isn’t always possible to remove these kind of fake anti-virus programs, but it’s certainly possible in some circumstances. My dad wanted a list detailing how exactly I removed the rouge virus. Here it is!

  1. Open Task Manager.
  2. Look for processes that do not belong.
  3. End any processes that should not be running.
  4. Use HijackThis to find any secret processes.
  5. Research processes on The Internet to learn about their behavior.
  6. If you can continue, you can use SuperAnti Spyware and MalwareBytes to remove general problems.
  7. Use specialized removal tools if required.
  8. After sanitizing, use Sysinternals Autoruns to see lingering auto-running programs.
  9. Remove crapware.
  10. Run CCleaner with everything checked on the main pane.
  11. Run the CCleaner registry cleaner twice.
  12. Run Windows Update.
  13. Put any files on the desktop into a folder in My Documents.
  14. Remove all desktop icons except for: My Documents, Firefox, Chrome, My Computer and the Recycle Bin.
  15. Install the latest Firefox.
  16. Install the latest Chrome.
  17. Install AdBlock Plus for both Firefox and Chrome.
  18. Defrag computer.
  19. Run Windows Update again.
  20. Restart a few times to verify viruses are gone.
  21. Install Microsoft Security Essentials.
  22. Run CCleaner.
  23. Done.

To do what I did, I think my dad’s friend would have had to pay at least $300 to BestBuy or similar computer store. You can get rid of a virus either doing it like I did, or reinstalling Windows. The latter takes an hour and is usually fool proof while the former could take anywhere from an hour to days and it’s certainly hit or miss.

Terminal Tip – sagi – sudo apt-get install

No, it wasn’t my idea. johntkucz from a thread on the Ubuntu Forums mentioned that he made an alias, sagi.

His reasoning for it is, “to make my ‘trip to the linux store’ even more ridiculously easy.” I think that sums up the power of apt-get and Linux quite nicely. sagi becomes a bonus in that case.

You could make the alias be anything, but the acronym is fitting because it describes each of the key pieces of sudo apt-get install.

alias sagi='sudo apt-get install'

With this, you could install my new favorite text editor just like this: sagi kate. It would probably prompt you for your password and then it would install kate thereafter. It’s a shortcut that looks nice and saves time.

Update

After writing the post and actually using this in person and via ssh, it seems that sagi only remains during the session it is defined in. To make it stay around for ever, put it in your .bashrc file in your home folder. That should do it.

Happy apt-getting.

Next>

© 2013 Ryan Rampersad.