Blog Navigation
Partners
Latest Activity
Phil gives the source code for implementing a MySQL singleton class in both PHP and Python.
Posted on: January 22nd, 2012 by Famous Phil
Its now time to become serious with my blog again after such a long lapse in real content.
When building new applications, it always seems like I start with the grand picture requiring no massive data storage and shortly after I begin, I find myself needing a database connection. I’ve made the mistake several times now of not starting with a dedicated database class that connects to MySQL, and I always find myself googling for pre-made classes that don’t do exactly what I need, so I’ve decided to post my own for future reference. As a result, I’m going to make sure that when I Google, I find my own reference before someone else’s
Hopefully this is useful to someone else.
PHP’s MySQL singleton class:
<?php
// Copyright (c) 2012 Philip Matuskiewicz www.famousphil.com
// To use:
// require_once("Mysql.php");
// $db = new Mysql();
class Mysql{
private $server = "localhost";
private $username = "";
private $password = "";
private $database_table = "";
private static $instance;
private function __construct(){
$this->connect();
}
public function connect(){
mysql_connect($this->server, $this->username, $this->password);
mysql_select_db($this->database_table);
$this->q("set names 'utf8'");
}
//query the database
public function q($query){
$r = mysql_query($query);
return $r;
}
//returns an array containing all the rows that were returned
public function qr($query){
$r = $this->q($query);
if (mysql_num_rows($r) > 0) {
$res = array();
while ($arr = mysql_fetch_array($r)) {
array_push($res, $arr);
}
return $res;
} else {
return null;
}
}
//number of rows returned
public function nr($query){
return mysql_num_rows($this->q($query));
}
//last inserted row id is returned
public function lid(){
return mysql_insert_id();
}
//close the database connection
public function c(){
mysql_close();
}
public static function singleton(){
if (!isset(self::$instance)) {
$c = __class__;
self::$instance = new $c;
}
return self::$instance;
}
public function __clone(){
trigger_error('no clone', E_USER_ERROR);
}
}
?>
The Python MySQL singleton implementation is similar, but includes an external file named config.py in this example
--> config.py (configuration information for the MySQL class)
dbhost = "localhost";
dblogin = "";
dbpassword = "";
dbname = "";
--> MySQL.py (The MySQL class)
#!/usr/bin/env python
# Copyright (c) 2012 Philip Matuskiewicz www.famousphil.com
#to include / use, insert the following lines in the code
#import imp;
#mysql = imp.load_source("MySQLConnector", "PATH_TO_PYTHON_FILE/mysql.py").MySQLConnector();
#result = mysql.tryquery("Mysql Query Here");
import sys;
import os;
import string;
import base64;
import MySQLdb;#mysql library (you will need to install this on the system)
#MySQL Singleton Class
class MySQLConnector(object):
_connection = None;
_instance = None;
def __init__(self):
try:
if MySQLConnector._instance == None:
MySQLConnector._instance = self;
MySQLConnector._instance.connect();
except Exception, e:
print "MySQL Error "+str(e);
def instance(self):
return MySQLConnector._instance;
def get_connection(self):
return MySQLConnector._connection;
def connect(self, debug=False):
try:
for line in open('includes/config.py'):
#this can be dangerous, but sources / executes lines in config.py, which contains the db info
#alternatively, you can just set the variables here manually
exec('%s = %s' % tuple(line.split('=', 1)));
MySQLConnector._connection = MySQLdb.connect(dbhost, dblogin, dbpassword, dbname);
if debug:
print "INFO: Database connection successfully established";
except Exception, e:
print "ERROR: MySQL Connection Couldn't be created... Fatal Error! "+str(e);
sys.exit();
def disconnect(self):
try:
MySQLConnector._connection.close();
except:
pass;#connection not open
#returns escaped data for insertion into mysql
def esc(self, esc):
return MySQLdb.escape_string(str(esc));
#query with no result returned
def query(self, sql):
cur = MySQLConnector._connection.cursor();
return cur.execute(sql);
def tryquery(self, sql):
try:
cur = MySQLConnector._connection.cursor();
return cur.execute(sql);
except:
return False;
#inserts and returns the inserted row id (last row id in PHP version)
def insert(self, sql):
cur = MySQLConnector._connection.cursor();
cur.execute(sql);
return self._connection.insert_id();
def tryinsert(self, sql):
try:
cur = MySQLConnector._connection.cursor();
cur.execute(sql);
return self._connection.insert_id();
except:
return -1;
#returns the first item of data
def queryrow(self, sql):
cur = MySQLConnector._connection.cursor();
cur.execute(sql);
return cur.fetchone();
#returns a list of data (array)
def queryrows(self, sql):
cur = MySQLConnector._connection.cursor();
cur.execute(sql);
return cur.fetchmany();
#end class MySQLConnector
Tags: mysql, php, Python, Singleton, Source Code
Posted in Programming, Technology
|| No Comments »
Posted on: January 21st, 2012 by Famous Phil
Phil’s Introduction to the post: This will be the last guest post that I accept indefinitely that doesn’t deal with a difficult problem that the poster hasn’t directly solved (basically, the same things I blog about). I feel that these posts are deteriorating the quality of my site, and guest posters are simply looking for high page rank back links to their sites, instead of writing unique, original content that creates better rankings. In a few days, I’ll be releasing some python source code for MySQL connectivity, Nginx for high traffic sites, and other tricky problems that I’m currently dealing with in attempt to re-rail my site back onto topic. Anyways, Rebecca Jones has written about Listening to Spotify on Linux (without WINE which is a Windows Execution Emulator for Linux), I hope that you enjoy her guest post.
Listen To Your Music In Spotify For Free Without Wine
Music aficionados who delight in listening to millions of tracks through Spotify’s free version but feel petered out of needing Wine at the same time have just got some good news to enjoy. The DRM-based music streaming service now announces a new free version specifically for Linux users. Spotify for free will now enable listeners to indulge in gripping tunes without calling out for Wine.
Integrated with a host of great user –friendly features, the music streaming application allows users to listen to millions of songs, any time they like. One can simply rifle through Spotify for a particular song and start playing in unprecedented clarity. For those unaware, Spotify is music based software which provides users with an intuitive medium to search download and play their favorite songs.
Almost like a new music collection, Spotify brings forth convenient access to unlimited tracks and features compatibility with home audio systems and smartphones. The app also lends support to users’ desktop and Mac for tunes that should follow everywhere. At the same time, the app allows users to discover and share music with their closed ones. In fact, users can even hear what their friends are listening to – just by hitting ‘play’ on any music post.
However, Spotify distinguishes from Last FM and Pandora in a couple of significant ways. To state, the app lets music buffs listen to entire albums on demand. But, be careful as there are certain obnoxiously genre-defying advertisements contained. Irrespective of the pros and cons that it comes with, the app still emerges to be an ideal pick. With this one around, people can seamlessly search up and down for songs and share them with amigos.
Although Spotify was extended to several platforms, the software did arch shoulders for those who would always need Wine just to listen to the music. Previously, the Linux version for Spotify used to function merely with paid accounts. Nevertheless, the free version of Spotify for Linux is now anticipated to make things simpler for enthusiasts by large.
The native Linux adaptation starts up pretty quickly and does not gulp down much of a listener’s time while delivering a better experience than Wine. As far as the enrollment is concerned, users will be required to register for an account at Spotify’s official website before kicking off their musical journey. But, a bit to dismay, registering feels a dearth of a Facebook account since the company has made it mandatory to have an account on the stated social networking site.
Besides Spotify for free without Wine, the music streaming service can be downloaded either in Premium which makes users shell our £9.99 per month or in Unlimited which costs just about £4.99 per month. Those who do not wish to fork their pennies out can simply download the free version. However, irrespective of which subscription has been settled upon, the software ensures a thorough, rich music experience. So, what are you waiting for? Just head towards Spotify and we believe the rest you know!
About the author: Rebecca is a blogger by profession. She loves writing on environment and technology. Beside this she is fond of books. She recently bought a AGP Graphics Card. These days she is busy in writing an article on Magnetic Earrings.
Tags: Linux, Spotify, Wine
Posted in Technology
|| No Comments »
Posted on: December 22nd, 2011 by Famous Phil
I bring you a guest post from Melanie Slaugh. She does get a majority of this topic right, except for this is also an excellent way to get humans to click blindly too. I set up a twitter bot at one point that posted a shortened URL to a website that I worked on to artificially boost its traffic and market it. Surprisingly, posting to the trending topics on twitter with a related link and text generates a lot of traffic since a lot of people click links blindly. Anyways, here is Melanie’s post.
URL shortening sites like Tinyurl.com and Bitly.com are the new haunts for Tweeters who do not want long URLs to consume their restricted typing space. However, shortened URLs have another, more insidious use. They allow spammers and hackers to evade the timeworn email filters and gain entry to your inbox.
Most email anti-spam counteragents were generated even before the usage of embedded URLs in emails, not to mention abridged ones. Most contemporary anti-spam programs track back the URL to see if the site it originates from is hazardous. However, a shortened URL can be utilized by hackers in two distinctive ways.
The first way is simple. They tie the site they want you to get directed to into one of the identified and reliable URL shortening sites available for free to the community. Because the URL shortening site itself is reliable, the link is trusted. However, the link does not connect you to the URL shortening site; it connects you where it was originally fixated.
Secondly, hackers can get especially resourceful. Once the email program’s anti-spam filters determine the misapplication of the URL shortening sites, as some have already done, hackers produce their own URL shortening sites. Basically, they shorten a site that’s previously shortened. So, when you click on the link, you get forwarded not once, but twice. The first transferal is safe, the next is a hackers.
This is “yet another example of cyber-criminals adopting new technology to bypass traditional security measures,” said Bradley Anstis, vice-president of technical strategy at M86.
“A lot of the traditional anti-spam engines were developed before Twitter, so they are not geared up to recognize embedded URLs as seen in blended email threats in spam, let alone shortened URLs that link to malicious, or compromised Web pages,” Anstis said.
Some frightening statistics:
In May 2011, the global ratio of spam in email traffic from new and previously unknown bad sources increased by 2.9 percentage points since April 2011 to 75.8% (1 in 1.32 emails).
The global ratio of email-borne viruses in email traffic from new and previously unknown bad sources was one in 222.3 emails (0.450 percent) in May, a decrease of 0.143 percentage points since April. (From Net-security.org)
So, what can you do to guard yourself from hackers? For one, never click on an email link if you do not have confidence in the sender. Two, even if you do have faith in the sender, do your best to get to the link organically, meaning follow the regular method. If you are tracking a delivery, go through the main website in the place of clicking on the link. These modestactivities will help to keep your computer, and the data it holds, safe from hackers.
Author Bio
Melanie Slaugh is enthusiastic about the growing prospects and opportunities of various industries and writing articles on various consumer goods and services as a freelance writer. She writes extensively for internet service providers and also topics related to internet providers in my area for presenting the consumers, the information they need to choose the right Internet package for them. She can be reached at slaugh.slaugh907 @ gmail.com.
Posted in Technology
|| No Comments »
Posted on: November 21st, 2011 by Famous Phil
Most of the Matthouse infrastructure is running on old Celeron processors and limited RAM, you may laugh at me, but that hardware has been very reliable and has lasted Matthouse for the better part of 3 years, and some of it may continue to power Matthouse well into the future! But there are some applications out there that require a little more juice to run well, and (unfortunately) Exchange falls into this category. I say it is unfortunate since the Exchange server hosts a handful (< 10) mailboxes, yet it costs quite a bit to maintain compared to other Mail Transfer Agents (MTA). So anyways, this blog is dedicated to the procedure that I took to migrate Exchange over to brand new, shiny, fast hardware.
First, I had Server 2008 R2 Datacenter as my operating system on both the existing server (denoted double) and the new server (denoted ruby). The servers could clearly communicate with each other within the same datacenter as well so that file / data transfers could be effective. The first thing to adding any server is to give the new server a name and know its network configuration details ahead of time. I’m not going to go into details about how to install Windows, since it’s pretty simple. Just make sure that you have the correct drivers installed for your server after the installation completes.
Note about installing Windows: just so that you don’t run into any issues with your system, make sure that your primary hard drive is attached to the first port for your motherboard’s interface, in my case, the first hard drive was connected to SATA 0. If you don’t do this, you’ll run into a lot of problems and waste a lot of time (like I did!). In addition, make sure that your BIOS has AHCI enabled prior to installing Windows, this also caused problems in my scenario. Once Windows is installed, make sure that you can disable write caching on your hard disk without the operating system freezing (in computer management, under storage, right click the disk and optimize for quick removal). If you followed the above, this shouldn’t cause Windows to hang, and will prevent Active Directory from incapacitating your system during the restart phase of the installation. In addition, this is a good time to name your computer, join it to some default workgroup, add remote administration features, and change the time zone / clock settings.
Before continuing, I’d also recommend disabling Internet Explorer’s advanced security features; this is done by going to the computer management main screen and scrolling down, finding IE ESC and turning it off (acknowledging all of the warnings). If you keep them on, you’ll find yourself doing way too much work to download necessary applications, etc. These features are only useful if you plan on doing general web surfing on the server (which I would not recommend for security reasons). I also activated windows, ran all the necessary windows updates (several reboots and optional updates as well). After this all has been done, I ended up rebooting the machine a final time.
At this point, I installed several applications (using IE to get Google Chrome initially).
Tags: active directory, exchange, exchange 2010, migration, owa, Transfer, upgrade, windows
Posted in Hosting / Server Administration, Technology
|| No Comments »
Posted on: November 17th, 2011 by Famous Phil
I bring you a guest post from Sarah James ( contactsarahjames [at] gmail [dot] com), this post is more or less Sarah’s view of Charter Communications which is a Cable ISP.
The Charter internet service is great when it works – not so much when it doesn’t. That’s not fully Charter’s fault of course, or at least it wasn’t in my case – the root of my problem was the fact that my new office existed on a street that has only just been built, and which had yet to be registered with any database up to and including the ne held by the Post Office.
Not ideal, especially when the Charter internet guys were due to show up on day one and install the system for me. Here’s how my tale of woes began:
The Post Office eventually updated my street address. But that updated didn’t appear anywhere outside of the Post Office’s own database for three weeks. I’m assuming that delivering fast internet updates isn’t a priority for an organisation that sometimes has problems delivering letters on time, if at all.
The Post Office was only the start of my problems. I had to order my Charter internet connection based on the address of a nearby building, which meant, when Charter came out to install it, that they wouldn’t fit it in the building I actually own. Fair enough. But it took ages to sort the whole thing out, going backwards and forwards between the Poster Office and Charter until I was blue in the face and a cast of thousands had turned up at both my actual address, and the address down the street I’d been using to get my stuff delivered in the first place.
I tried talking to Charter directly but of course you either end up in a queue a mile long or you have to use the online web chat assistant – who, given the speed and clarity of the Charter internet connection (once you’ve finally had it installed0, went unbelievably slowly. It was kind of like talking to a backwards six year old.
Question: with all this internet power at their fingertips, why are the web companies so bad at direct communication with their customers? On the one hand they sell these amazing services, which allow you to segue all sorts of communications requirements into a single connection (the payment plan is good too) – and on the other, they make communicating with them next to impossible (unless you’ve got all day to sit around doing nothing else except trying to get through to them).
Fortunately my Charter internet service has now been sorted – and I am enjoying the rapid broadband connection that I was promised in the first place. I have no beef with the quality of the service and the capabilities of the connection. I would just like to know why it takes around 12 different engineers to install a simple web connection. Though as I say the business with the Post Office can’t have helped much.
So come on, Charter, get it together in the back operations department. Use your own technology to power your online web assistant and maybe we’ll be able to get something done!
About the author:
Sarah James is associated with various internet security related companies including broadband expert as their freelance and staff writer. She has been linked with some of the best web media companies and offers various ways for internet solutions. She excels in writing articles related to internet security, charter internet plans, comcast deals etc.
Tags: Cable, Charter, ISP, problems
Posted in Technology
|| No Comments »
Posted on: November 13th, 2011 by Famous Phil
It has been some time since my last post, and I think this is going to be the norm for at least the next year, sadly. Today’s topic is based on information that I needed about IMAP (Internet Message Access Protocol) last week. Basically, I’m developing an application for conceptual.ly that allows for normal users to enter their login information for their email and then the application will unsubscribe them from internet mailing lists that people often dislike, yet get plentiful email from. Since the solution is completely artificial (and requires no human intervention), it exceeds what others have done in the past.
Unfortunately, computers are not able to think and identify patterns without a lot of help and special cases already entered into databases for them to compare against. Thankfully, emailing lists have certain unique identifiers that allow this application to effectively identify and remove users from mailing lists, although I will not disclose exactly how it is done since that research was done on company time and therefore remains property of Conceptual.ly. But I did want to take the time to publish a cheat sheet for those of you who need to communicate with IMAP servers via telnet.
CONNECTING: The general command to telnet to an insecure IMAP server is “telnet imap.server.com 143”, remembering that IMAP runs on port 143. If you’d like to connect through IMAPS over port 993, your computer will need OpenSSL and the command to do so is “openssl s_client -connect imap.server.com:993”. OpenSSL will take care of all the connection securing / establishing for you, the commands following the initial connection are exactly the same.
IDENTIFIERS: IMAP commands start with an identifier, I’ve seen “. “ as the identifier (a dot followed by a space) and I’ve also seen “a1 “ (a1 followed by a space) as the identifier. I’ve also seen incrementing the 1 to 2, 3, etc work, and reading the RFC was not specific to what had to be used. I typically use “. “ as my identifier and fall back to using a1 for all of the commands I enter, it has worked for every IMAP implementation I’ve dealt with thus far (including Gmail, Dovecot, AOL, and Exchange).
LOGIN: To login to the IMAP server, you need to enter the identifier followed by “login username password” replacing username and password with the appropriate login information. Note that your username may be your email address.
LIST: This command is typically followed by a login and lists all of the available mailboxes in the IMAP account. The syntax for this command is list “” “*” which simply gets all of the mailboxes and subfolders. The usual response is * LIST (\HasNoChildren) “.” “INBOX” which can easily be parsed, the \HasNoChildren can change if there are children. Usually with children, the output will make the actual folder (the last segment of the output) contain the parent and a . so that you can simply use this to formulate a connection to a specific folder to retrieve messages, etc. This isn’t always the case, so it is helpful to use IMAP over telnet to verify the response of the command for the specific IMAP server that you are connecting to.
STATUS: This command will return information about the folder you inquire about, I’ve only seen it return the total messages and unread messages in a folder in my experiences. The syntax of this command is “STATUS FOLDER (flags which are optional)”.
SELECT: In order to search or retrieve items from a folder, you must first select that folder. The syntax of this command is “SELECT FOLDER”.
SEARCH: This command has some ambiguity that caused me some difficulty that I will get to shortly. The syntax for search is “SEARCH (PARAMS)”. The parameters are identified in the RFC3501, but there are some specifics I’d like to talk about. First, I’ve found that SENTSINCE does not need to be in (), instead you would do “SEARCH SENTSINCE 01-01-11 (PARAMS)”. Next, if you want to search for more than 2 items using the OR syntax, you would need to use nested ORs, this might look like the following: “(OR (OR HEADER From yahoo.com BODY hello) BODY phil)” to search for a message that might be from yahoo.com (partial match) with the body containing hello, or just having “phil” in the body. This works similarly for the AND parameter. When search returns, it returns a space separated array of numbers which are identifiers for the FETCH command. Remember that to search, you have to SELECT the folder to search first.
FETCH: This command will retrieve messages from a folder, you must have selected that folder first before you can retrieve a message. Typically, messages are identified by a number which the FETCH command uses, so a SEARCH is generally executed before fetching messages. The syntax is “IDENTIFIER FETCH (PARAMS)”. IDENTIFIER is the number that search returned, and there are numerous PARAMS that you can do. I’ve seen (RFC822) work at grabbing the entire raw message source (both headers and body), but in AOL’s implementation it does not, so I’ve reverted back to getting the header and body of each message through 2 fetches, the first parameter is (RFC822.HEADER) and the second is (RFC822.TEXT). I do not believe that IMAP servers return a decoded version of the message in all cases, so I also used an email parsing engine in Python to decode the message source that these commands returned.
LOGOUT: The syntax for this command is “LOGOUT”. It simply disconnects you properly from the IMAP server.
For the needs of my program, these were all the commands I needed, so I’d strongly suggest that you look at RFC 3501 at http://tools.ietf.org/html/rfc3501 for more information about the IMAP protocol and its usage.
I would also like to note that GMail has added commands to their implementation that better follow the speed and reliability of their web interface, those commands can be found at http://code.google.com/apis/gmail/imap/ (this was kind of hidden from my initial searches for information about GMail’s IMAP implementation, so I wanted to make this more visible). If you use standard IMAP commands on Gmail, you can expect it to be much slower than other IMAP servers and much slower than their web interface.
Finally, AOL’s IMAP implementation doesn’t allow searching certain header fields and the body of the message, so I’d recommend testing your commands ahead of time to ensure you are getting responses that you expect. As a tradeoff, AOL’s IMAP implementation is very fast at returning messages via the FETCH command, so where the SEARCH lacks ability on AOL’s IMAP server, the speed in downloading messages far makes up for this lack of functionality. It is also possible that AOL’s IMAP implementation has certain extensions that I didn’t notice, so you may want to look into that possibility also if you’re dealing with their IMAP servers.
Hopefully this blog post can help someone save time so that they don’t have to do as much searching as I had to for connecting to IMAP servers.
Tags: email, IMAP, IMAPS, OpenSSL, Protocol, telnet
Posted in Programming, Technology
|| No Comments »
Posted on: October 27th, 2011 by Famous Phil
I bring you a guest post from Nadia Jones this week! I will return next week with a simplified IMAP reference guide.
Over the past few months, a large subset of the Linux community has been all ablaze in disagreement and controversy. The disagreement has been over a dramatic change in interface to a popular operating system (referred to in the Linux world as a “distro”) called Ubuntu.
Some Linux and Ubuntu Basics
Before we get into the details, I think it is important to understand the basics of Linux and Ubuntu. Linux refers to the kernel of the operating system, the core under-the-hood process that handles things like hardware management, etc. The Linux kernel is completely open source, so there are many distros wrapped around it, each with their own combination of software, graphical front-ends, and what have you. Ubuntu, maintained by a company called Canonical, is believed to be the most popular free Linux distro.
Ubuntu’s New Release: Unity
Up until version 11.04, which released April 2011, Ubuntu has used a graphical front-end called Gnome. It is considered stable by many users and has had a long period of usage in Ubuntu. With the release of 11.04, Canonical experimented with a new front-end called Unity. So far, users have complained Unity being very buggy, counter-intuitive, and oversimplified.
For example, Unity has a new docking bar locked on the right side of the screen that is very similar to Apple’s docking bar at the bottom of Mac OS X. The problem with this dock is that it looks exactly the same regardless of which programs you have open on your system. So if you are juggling four separate windows of Google Chrome, and all of them are minimized, there is no taskbar-like setup to easily pick and chose which one Window you want. You can only see the one Google Chrome logo on the dock. Click it, and all your Chrome windows appear on the screen at once. There are many examples like this, in which everything seems to take one or two clicks too many. Essentially, they tried taking a page from Apple and achieved very little.
Perhaps the bigger upset is the buggy elements of Unity. Linux distros (including Ubuntu) are known and developed for their high efficiency and reliability. Very modest computer systems can run on Linux distros with no problem for hundreds of days, with no problems and requiring no restart. With Unity, many users are reporting that they have to force restart their systems every work or so because the unity dock locks up, windows will freeze, or any number of glitch, buggy reasons.
Beyond User Experience, Where’s the Controversy
Bugs are a part of any operating system, and in due time, they will likely be fixed. And the flaws of the user interface can be tweaked and customized with enough frustration and elbow-grease, so this shouldn’t be a permanent source of contention either. With two of the biggest complaints of Unity being fixable, this begs the question: Why is there all this controversy?
The most sensible explanation lies in the normative ethics of open source software development. There have been countless cases of developers making mistakes and bad decisions in creating and updating software. Typically, however, the developers listen to the feedback of their users and fix their mistakes.
Yet, when Mark Shuttleworth of Canonical got overwhelming feedback from Gnome developers that they didn’t like Unity and didn’t think it was a good fit for their system, Shuttleworth shifts Ubuntu to use Unity as the default front-end anyway. This effectively forced a split in the Ubuntu community. Many intermediate to advanced users will either revert back to using Gnome or find a different distro altogether. Yet Canonical is pushing forward as if there is no disagreement or problem whatsoever.
Bottom Line
While I do feel like this whole situation is a complete blunder on Canonical’s part, I do not think it will lead to any type of dramatic end to the company. Sure, some great developers and innovative users in the community may leave, but Ubuntu’s grasp over the Linux community is too big to lose hold.
I do think that Unity is fundamentally more cumbersome than Gnome. For a interface that is spreading to more and more school districts, public libraries, and government buildings due to its free pricing and ease of use, I worry that Unity is a step in the wrong direction. Still, I’m sure that the fact it is free will prevail over whatever ease of use obstacles Unity has.
Author Bio:
This is a guest post by Nadia Jones who blogs at online college about education, college, student, teacher, money saving, movie related topics. You can reach her at nadia.jones5 @ gmail.com.
Tags: ubuntu, Unity
Posted in Technology
|| No Comments »
Posted on: September 21st, 2011 by Famous Phil
Last week, I finally broke down and got an iPad. I did this partially because I wanted a new toy, and partially because I wanted to find out what the hype is with this gadget. I’ve had several recommendations saying that I should buy one from many friends in the past, so I finally took the advice and jumped head into a product that I probably wouldn’t have looked at without the positive encouragement. The final piece that really motivated me to get this product was that I would like to learn to develop for it, and I’ve found that the only way to effectively develop for anything, denoted X, is to be an active user of X.
After a week with the device, it makes sense to finally make an unbiased review of it. When I first got home with it, I was really impressed with the design of the packaging. Only Apple would put the iPad into a backpack style bag that’s really durable to carry out of the store, in addition, the packaging for the iPad was also well thought out. There were tabs that easily allowed it to be pulled out of the box (no turning the box upside down, etc to remove it). So after the unpackaging of it, I plugged it in to find that I needed to install iTunes to set it up. This has got to be one of the worst things about Apple products, because I cannot stand iTunes, it’s just so bloated, and I manage my music library through other means! Anyways, I installed iTunes and accepted the license agreement. I couldn’t do much else though because iTunes couldn’t connect to my AppleID account because I firewall my internal network very heavily (which is fine). Accepting the license agreement was enough to get the device to work without a computer; I quickly enabled the 3g access through Verizon and signed into the Apple Store using the 3g connection.
My first impression of the 3g access on my iPad was a very positive one, I actually get a little signal on the Manhattan, NY Subway which most phones I’ve used don’t even get, and I think this is because the antenna on the iPad is bigger. This signal is just enough to check email and such, nothing too demanding. I also get roughly 1.7Mbps down, and .42Mbps up on the 3g connection which is quite good for a Verizon mobile connection (EvDO at least, LTE would be pretty crappy). I also love the fact that 3g is built in… so there is no tethering or anything of that sort. Unfortunately, there are a few downfalls to the 3g model. The first is that it will cost more and there is no way to sign up for a long term contract to get a big discount on the device (unlike phones). I was pleased to find that the 2GB mobile data plan was only $30/month, which is well within my price range and usage range. There are several other plans as well that are just as great. If I were to recommend an iPad to anyone, I would strongly suggest the 3g model, just because you can use it anywhere without having to worry about being within range of a wireless signal.
I bought the smart magnetic cover for my IPad because I figured it would adequately protect it. Although it does that, it really helps make the unit more dirty, especially if you goto a restaurant and put it on the table, since the cover that touches the screen also touches the table unless you put it in that triangle stand arrangement. For general movement, the cover does a good job at protecting the screen. Looking back, I wouldn’t change the decision to get the smart cover, but I do need to look into a carrying case / solution for this iPad. It is too big to carry in a pocket, but it’s too small to put into my laptop case, and that presents a problem. I currently carry it around on my side everywhere, which isn’t awful, but does make me more of a target when annoying people ask for money on the streets (it is NYC after all). I haven’t quite found the perfect solution to this yet, but I’m sure it will come with time and more exposure to my options.
Apple is known for their App Store, and I someday hope to make some apps that appear in it. For now, I downloaded several apps that made sense for my particular usage of the iPad… I’m going to just briefly mention them now. The first application I got was Outlook Mail Pro by Code Before Dawn, which was meant to give a very similar interface to Outlook. It works well for mail because the interface is well thought out (perhaps a bit better than the default mail app’s interface), but I still prefer using the built in Mail Application support for Exchange when it comes to the calendar, contacts, and task list access. I also bought the iTap RDP application for remote desktop; it saves passwords and allows several bookmarks to remote desktops. I use this for connecting to my remote windows computer for Trillian instant messaging and handling other issues that only a true computer can do. Over 3g, the speed is phenomenal for response times to clicks and such. I also bought the Remoter VNC application which supports SSH, Telnet, VNC, and other remote access protocols. Remoter uses Putty keys for authentication which is why I sprung for this application over its competitors, and so far I’m very happy with it. Other free apps that I got were Facebook, speed test, Skype, yelp (restaurant ratings), and Sirus XM (online subscription required). Remember that Skype and Sirius will use a lot of data, so I tend to use Wi-Fi when I use those apps. I did try a video chat on the Skype application and I believe that it works better on my iPad than it does on my main computer!
I will now go onto usability of the iPad. When I first got the iPad, I was concerned that I wouldn’t be able to get used to the keyboard. Honestly, at first, it was difficult to get used to since there is no bump on the F and J keys (home keys), so you have to look down to place your hands. It was also weird not being able to rest my hands on the keys. Overall though, I did quickly adjust to it and even with big hands, I can type fairly well on the keyboard. One thing I did notice is at first my hands would always drift away and hit the wrong keys, but somehow that has gotten far better, I’m not sure if Apple is doing error correction or if I’m just getting better at keeping my hands in a consistent position while typing. The second usability issue was the limited nature of most Apple products; fortunately, I haven’t hit any of these limitations that I couldn’t work around (e.g. remote desktop). So far, my iPad is quickly replacing most of my computers since I’m quite used to it now (I’m actually typing this up on my iPad). The battery life on the iPad is great, I haven’t had a single issue with battery life, and the lowest I was able to get the percentage to was 65% remaining, and that was after a full day of using it while visiting several parts of Manhattan. This segue takes us into a side topic about the maps application. So far, the iPad tends to be more reliable than my phone when it comes to placing a dot on the built in map telling me exactly where I’m at.
Overall, I love how fast the iPad is to display anything. Unlike other things I’ve used, I can usually click something on the iPad and it loads instantly with very little delay. I really like this about most Apple products and I wish that other competitors (e.g. Android) could make similar advancements in speeds for embedded devices. Oh well, I’m sure that Google and their partners are working on this, and all good things take time to perfect.
So there you have it! Overall, I would recommend the iPad to anyone, but at the same time, I really do think that you have to take the plunge yourself to discover if it is right for you. I took the chance (with a 14 day return policy), and I found out that I definitely have great uses for my iPad, and I’m quickly learning why others strongly recommend it.
As always, thanks for reading, and I hope to post more frequently now that things are settling down in my life and are starting to become the same old routine, just another day. I have a few interesting blogs on business and high traffic hosting coming soon, I just need the time to thoroughly review what I’ve already written for them so that they’re as clean and concise as possible.
Also, in the near future, FamousPhil will be getting a new, professional design (mobile and full computer oriented!), so that is something that you can look forward to!
Tags: Apple, iPad, review
Posted in Mobile Technology, Personal, Technology
|| 2 Comments »
Posted on: August 22nd, 2011 by Famous Phil
Anymore, it seems like posting here is a seldom activity because I don’t often deal with server administration issues any longer (although I am working on changing that
). Today, I was asked to reset the password on a Mac Server because the user didn’t remember the password. Personally, I don’t know how a server oriented password can be lost, but whatever, I guess I’ve seen it all now
Mac, like Linux and its BSD roots, has a flaw when you have physical access to the machine. Basically, passwords are stored as password hashes in a simple file on the server. To change the password of any user account, you basically have to gain write access to the said password (or shadow) file and change the hash to something that matches the new desired password. Typically, this is very easy to do for any kind of Linux or BSD operating system. For all of you Windows fans, Windows stores the passwords encrypted in SAM files (if I recall correctly), and there are also password reset disks available that you boot from and overwrite the administrator account password with your own password. Once again, resetting a password is very easy to do to gain access to a machine provided you have physical access. One tiny exception to this rule on every platform, if the encryption feature is enabled on a user account (provided it exists), the files that were encrypted will never be readable again if you change the password using this method.
Since this is resetting the password of a Mac, I’m only going to cover the Mac OS. Mac, like Linux and BSD, has something called single user mode which is basically a recovery environment built into the operating system. When something doesn’t work properly, this environment typically boots and gives the local user (on the console) a command prompt that is running as the root user (or superuser). Typically in single user mode, the local hard disk is read only, but because you are root, you can simply change that to write mode. Afterwards, its a matter of changing the password. If you aren’t a single user mode fan, Mac even puts a reset password link in the utilities menu of their installation disk that does the work manually.
So, using the single user mode shell, here is the procedure to resetting the password of your mac:
Tags: Mac, password, reset, root, single user mode
Posted in Hosting / Server Administration, Technology
|| No Comments »
Posted on: July 3rd, 2011 by Famous Phil
Over the past couple of months, I’ve found that the script that I posted at http://famousphil.com/blog/2011/01/a-decent-backup-strategy-for-exchange-2010-sp1/ hasn’t been working perfectly for my needs. This relatively short blog is kind of a back track blog to explain the issues and provide some fixes for them.
The original script I posted does not verify that the backups actually completed. The emails I got were simply gibberish. I was willing to accept that for a while until during monthly maintenance when I manually verify backups, I was finding that backups didn’t always complete. I’ve tracked this down in the error logs and found that the memory in the server isn’t enough for the backups at times which has them fail at certain times. Due to the lack of user base on my server (4 light users), I can’t justify adding more ram (I currently have 4GB) because I’d have to upgrade the entire server. So instead, I did some RAM optimization and re-wrote the backup script to email me the actual backup names that completed successfully.
First for the tips. I recently learned that Active Directory can be modified from the backend, so using this, I modified the Information Store service (store.exe) in Exchange to only use at most 512MB of ram. I used the information at http://terrytlslau.blogspot.com/2011/03/limiting-exchange-server-2007-and-2010.html for doing this, I briefly repeat the procedure here in the even that this link is no longer reachable.
1. At Domain Controller, login as a Domain Administrator. 2. Click "Start", enter "adsiedit.msc" into the search box, hit enter. 3. Right-click "ADSI Edit", select "Connect to". 4. Enable the Naming Context view, click ok to connect 4. Under the "Naming Context" menu, select "Configuration". 6. Expand to "Configuration > Services > Microsoft Exchange > > Administrative Groups > Exchnage Administrative Group > Servers > > InformationStore". 7. Right-click "InformationStore", select "Properties". 8. Select "msExchESEParamCacheSizeMax". 9. This value is set in pages, in Exchange 2010 the size is 32KB/page; Exchange 2007 is 8KB/page. Simply figure out the number of pages for the amount of ram you want to limit store.exe to using. For instance, if you want to limit the Database Cache to 4 GB of an Exchange 2010 server, set msExchESEParamCacheSizeMax to 131072 (4 GB = 4.194.304 KB / 32 KB). If you want to limit the Database Cache to 2 GB of an Exchange 2007 server, set msExchESEParamCacheSizeMax to 262144 (2 GB = 2.097.152 KB / 8KB). 10. Ok everything and restart the Information Store service (possibly the server)
After limiting the Exchange Information Store service, I simply restarted the Information Store service and that seems to have fixed the gouging memory issue.
As a second optimization procedure, I started tackling the IIS Worker Processes. Exchange has several application pools that it uses, you can think of an application pool in IIS as a separate instance of Tomcat or Apache for each website. Application Pools isolate websites to that they can’t affect each other. On the downside, application pools also hog a great amount of memory and for the features of Exchange that you may not use often (e.g. powershell, calendar, exchange control panel), it takes some time for these features to load initially (for me, its about 30 seconds). My solution was to limit Exchange to two application pools. For anything service related, I used the Exchange Service Pool (e.g. EWS, Powershell, Autodiscover), and anything client site based (e.g. OWA, Calendar, ECP, ActiveSync) in the OWA pool. I still do not know if any update to Exchange may reverse this or break this, but I do keep it in mind during updates. The result of doing this is that not only is memory consumption reduced significantly, but Outlook Web Access, Exchange’s Calendar display (for the public), and Exchange Control Panel all load much faster now since the overhead in IIS is already loaded. Of course, I wouldn’t recommend doing this unless you can’t easily upgrade the amount of memory in your server.
Finally, I will leave you with an improved export script that replaces the script in my previous blog at http://famousphil.com/blog/2011/01/a-decent-backup-strategy-for-exchange-2010-sp1/. This script verifies that all of the users were actually uploaded and emails the complete report to you (instead of some garble). I’ve found it to be very helpful in determining if a mailbox was failing to export to a PST without having to login to the file server and check. As always, use this script at your own risk, I am willing to provide limited support as time permits.
# Exchange 2010 SP1 Mailbox Export Script
# Originally from Steve Goodman.
# Modified by Philip Matuskiewicz for Matthouse.us / famousphil.com 1/2/11 FIXED *7/2/11*
#define information here
$server = "host.example.com" #server hostname
$users = @("Joe", "Mary", "Phil") #users to archive
$destination = "localhostpstbackups" #network share to backup to
$emailfrom = "server@yourdomain.com"
$emailto = "you@yourdomain.com"
#define some internal variables
$output = ""
$error = 0
$date = Get-Date
#check for errors
if (!(Get-ExchangeServer $server -ErrorAction SilentlyContinue)){
$output += "Exchange Server $server not found`n";
$error = 1
}
if (!(Get-MailboxDatabase -Server $server -ErrorAction SilentlyContinue)){
$output += "Exchange Server $server does not have mailbox databases";
$error = 1
}
#create a batch job if the above tests succeeded
if ($error -ne 1){
$jobname = "Export_$($date.Year)-$($date.Month)-$($date.Day)_$($date.Hour)-$($date.Minute)-$($date.Second)"
$output += "Job title is: '$($jobname)' `n"
Write-Output "Job title is: '$($jobname)' "
foreach ($mailbox in $users){
#remove existing PST file
if (Get-Item "$($destination)$($mailbox).PST" -ErrorAction SilentlyContinue){
Remove-Item "$($destination)$($mailbox).PST" -Confirm:$false
$output += "Existing PST was deleted (Normal): '$($mailbox)' `n"
Write-Output "Existing PST was deleted (Normal): '$($mailbox)' "
} # end if
#request a backup of the mailbox, Exclude the recoverable items / deleted items
$mailboxjobname = "$($mailbox)-$($jobname)"
New-MailboxExportRequest -BatchName $jobname -Mailbox $($mailbox) -FilePath "$($destination)$($mailbox).PST" -ExcludeDumpster -Name $mailboxjobname
$output += "Mailbox Queued: '$($mailbox)' `n"
Write-Output "Mailbox Queued: '$($mailbox)' "
} #end foreach
} #end $error -ne 1
#wait for the jobs to complete
$time = 0;
while ((Get-MailboxExportRequest -BatchName $jobname | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"})){
Write-Output "Waiting on backup, it has been $($time) seconds"
$output += "Waiting on backup, it has been $($time) seconds `n"
sleep 600 #10 minutes
$time = $time + 720;
} #end while
#check for any jobs that didn't complete
$incomplete = Get-MailboxExportRequest -BatchName $jobname | Where {$_.Status -ne "Completed"} | Get-MailboxExportRequestStatistics | Format-List
$complete = Get-MailboxExportRequest -BatchName $jobname | Where {$_.Status -eq "Completed"} | Get-MailboxExportRequestStatistics | Format-List
if($incomplete){
Write-Output "ERROR: Something didn't complete, output is '$($incomplete)'"
$output += "ERROR: Something didn't complete, output is '$($incomplete)' `n"
}
if($complete){
Write-Output "Completed Successfully, output is '$($complete)'"
$output += "Completed Successfully, output is '$($complete)' `n"
}
# Remove Requests and clean up
Write-Output "Cleaning up requests that were part of the job '$($jobname)'"
$output += "Cleaning up requests that were part of the job '$($jobname)' `n"
Get-MailboxExportRequest -BatchName $jobname | Remove-MailboxExportRequest -Confirm:$false
#verify that all the PST files were created...
foreach ($mailbox in $users){
#remove existing PST file
if (Get-Item "$($destination)$($mailbox).PST" -ErrorAction SilentlyContinue){
$output += "PST FOUND!!!: '$($mailbox)' `n"
Write-Output "PST FOUND!!!: '$($mailbox)' "
}else{
$output += "ERROR: PST NOT FOUND: '$($mailbox)' `n"
Write-Output "ERROR: PST NOT FOUND: '$($mailbox)' "
}
}
$SmtpClient = new-object system.net.mail.smtpClient("double.matthouse.org")
$msg = new-object Net.Mail.MailMessage
$msg.From = "$($emailfrom)"
$msg.To.Add("$($emailto)")
$msg.Subject = "EXCHANGE EMAIL BACKUP DETAILS"
$msg.Body = $output
$SmtpClient.Send($msg)
Write-Output "Script complete!"
Tags: backup, exchange 2010, powershell, pst, script
Posted in Hosting / Server Administration, Technology
|| 2 Comments »