James Andrews

Archive for August, 2009

Well worded responses better than immediate outrage.

by jandrews on Aug.28, 2009, under General Discussion

There was a time about 8-10 years ago where I would let my anger guide email responses. I would get angry, they would respond angrily and it would continue. Over the years I decided that it wasn’t worth it. I would get an email, and I would be furious. At that point I would stop everything. Close the laptop, and take a walk, play a video game, or even go to bed. Anything to take me away from what ignited my fury. This happened last night. I received an email, and immediately closed the computer. I stomped around the house, grumbling, trying to find an outlet. Doesn’t help that I’m in the middle of planning a wedding and spent the day frustrated over other things. After deciding to stop production on anything productive I was doing, and playing Settlers of Catan, just before bed, I gathered my thoughts, and calmly explained things in a way that was non provoking, and logical. When I woke up, I received an email saying that they agreed with everything I said, had a couple non provoking questions which I answered, and all was diffused and sorted out. The next time some one says something that throws you off the handle, take a walk, take a cold shower, do anything except respond. Then gather your thoughts and respond with intelligence, and thoughtfulness. You’ll feel better about it in the end.

Leave a Comment more...

iPhone App store the missing feature….

by jandrews on Aug.22, 2009, under General Discussion

I have a first generation iPhone. I’ve bought a bunch of crappy apps, and a lot of really great apps. Time and time again I go to the app store hoping to find something. Sometimes I do, sometimes I don’t. Then there are times I just want to browse the store. I find a lot of applications that seem interesting, but I don’t want to buy it at that moment. The problem Apple has failed to give you a mechanism to bookmark them. There is no iTunes app store “wish list”. Therefore weeks go by and I forget about an app that may or may not prove to be useful.

Every e-commerce engine on the planet has a wish list feature! Why not Apple’s iPhone app store?

3 Comments more...

It’s not camping if you’re on Facebook

by jandrews on Aug.14, 2009, under General Discussion

With the advent of the iPhone and other “app” enabled smart phones, more and more people can surf the web and from their phone. I have a few friends who “go camping”. More and more of them though they said they were camping were in fact connected to the internet. Chatting away online with people. Now I have nothing against you bringing your cell with you camping. You never know when an emergency will require someone to call an ambulance, or the fire department. I don’t even really have a problem with you using it as a camera and posting photos online so people can watch see what you’re doing. It’s almost like being there with you. What I don’t understand is the necessity to be online. Sit by the fire, make some smores? Take out your camera go find some wildlife to photograph, go to the beach an relax in the sun, but for crying out loud stop posting to Facebook, twitter and the lot. Camping is suppose to be a time where you disconnect from the digital world not connect even more!!!

I really want to go camping….

1 Comment :, , , , more...

Religion

by jandrews on Aug.12, 2009, under Religion

I try real hard not to discuss religion. Religion is one of those topics that once you open the door it is near impossible to shut it again without the force of 10 locomotives. I have too many people I know around me that are too invested in religion that it never ends well. Though every now and then though someone says something and I just have to say something.

Growing up I was surrounded by religion. My mother, many of her friends, and my grandmother are devout Catholics. When I was in High School we had minister for a Baptist Church who my mother associated with, and who I would often see walking between his house and the church, and who would approach me and try to discuss religion with me. I was a musician in high school. I played guitar, and liked to sing, and I remember one night he tried to criticize my music just because it was rock music. Yet he had never heard it, never listed to any of my lyrics. When I was writing music it was all about finding love. Nothing demoralizing, nothing satanic. Yet he had the nerve to criticize it. I remember about the same time my mother had signed me up for CCD, which I skipped on a regular basis. When my mother found out about it, and I was forced to go back, the teacher was surprised that I knew more about the subject matter than many of the students who had gone to class. I remember it clear as day actually. We were talking about passover, and the plagues that the God of Moses had sent down upon the Israelites. I remember the teacher asking everyone why they had to put lambs blood on the doors and the God would pas them over when killing the first born son of every family. Just an example of how much I was surrounded by religion as a child. When it comes to the stories, the ones that were iterated over and over in church, me with my insane memory, remembered all of them.

There was even a time afterwards where I found myself actually drawn to wanting to go to church, and I then a time in my early adulthood where I experimented with non-traditional religions trying to find something that felt right. Never feeling satisfied with any of it. The stories too unbelievable, the chanting, prayers/spells whatever you want to call them just felt too unrealistic.

With Christianity what drives gets at me the most is how blindly certain sects follow every word of a book that was written by men some 2000 plus years ago in a time when corruption was at it’s peak in the world. When kings and emperors would do anything to keep control of their domains. Not only do they follow it blindly, but they interpret it in unintelligent ways. It drives me absolutely batty. Did God really want you all to not use the intelligence he gave you to question things and to think for yourselves? I mean really, 6 days? Do you really think that the earth and all it’s creation was created in a 144 hour period? I just don’t understand how anyone could think that with all the scientific evidence showing that the earth has been around for billions of years before man. Did God just put it there to fake us out?

Now to the point of my post. Religion itself. How many wars have been fought over how many centuries because someone didn’t believe what someone else believed? How many times do I have to answer the door and tell the “Jehovah Witnesses” or the “Mormon” to leave me alone. What I like to call “Conversionism”. Their religious rightous duty to harass as many people as humanly possible to get them to become part of their cult. People shunning you because you are not of the same faith as you? Kicking you out after years of dedication because you child chooses a pagan faith over the one you raised them on. That’s right, they’ll kick you out if you screw up in their eyes. Is that the way of God? That’s no way I want to be. Trying to force religion into politics, school life, because they feel it is the righteous thing to do, without any respect for anyone else’s beliefs? Did God not teach you to respect others? Then show some respect even if you don’t agree with them. If you want to thank God before your lunch time meal please do, but don’t go dragging everybody else into it.

What do I believe? I believe there is something greater than all of us. What it is, I don’t know. I do know that I am not going to follow blindly something that may have happened some thousands of years ago written in a book by a man who is just as fallible as myself. I try to do what’s right. I try to show respect towards others and their beliefs. Please do the same, and try to understand that not doing so, and not respecting others beliefs is wrong, as much as you think it is not.

Leave a Comment :, , , , more...

php 5 Random String Generator

by jandrews on Aug.05, 2009, under PHP Development

I am sure people have written something similar 1000 times, but with time they fade from the internet. Today I will share with you my Random String generating php class. Are you ready?

<?php

    /**************************************************************************
    Copyright 2009  James Andrews  (email : contact at jamesmandrews dot com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation version 2 of the License

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     **************************************************************************  */ 

    class RandomString
    {

        /* static variables needed to create the random string */
        private static $alphas = "abcedfghijklmnopqrstuvwxyz";
        private static $alphasUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        private static $numbers = "1234567890";
        private static $specialChars = "!@#$%^&*()-_+=[]{}|:;>.<,/?";

        /*
         * Function to generate a random string of roman characters
         */
        public static function generateRandomAlphaString($stringLength, $type = "lower")
        {
            switch($type)
            {
                case 'upper':
                    $stringBase = self::$alphasUpper;
                    break;
                case 'mixed':
                    $stringBase = self::$alphasUpper . self::$alphas;
                    break;
                default:
                    $stringBase = self::$alphas;
            }

            return self::generateRandomStringWithLengthFromString($stringLength, $stringBase);

        }

        /*
         * Function to generate a random string of numbers 0-9
         */
        public static function generateRandomNumericString($stringLength)
        {
            return self::generateRandomStringWithLengthFromString($stringLength, self::$numbers);
        }

        /*
         * Function to generate a random string of numbers 0-9 and roman characters
         */
        public static function generateRandomAlphaNumericString($stringLength, $type = "lower")
        {
            switch($type)
            {
                case 'upper':
                    $stringBase = self::$alphasUpper . self::$numbers;
                    break;
                case 'mixed':
                    $stringBase = self::$alphasUpper . self::$alphas . self::$numbers;
                    break;
                default:
                    $stringBase = self::$alphas . self::$numbers;
            }
            return self::generateRandomStringWithLengthFromString($stringLength, $stringBase);
        }

        /*
         * Function to generate a random string of numbers 0-9 and roman characters and other special characters
         */
        public static function generateRandomStringWithAll($stringLength)
        {
            $stringBase = self::$alphasUpper . self::$alphas . self::$numbers . self::$specialChars;
            return self::generateRandomStringWithLengthFromString($stringLength, self::$numbers);
        }

        /*
         * Function takes a string length, and a "string from", and generates a random string
         * of stringlength, with characters withing "string from"
         */
        private static function generateRandomStringWithLengthFromString($stringLength = 0, $fromString = "")
        {
            $fromStrLen = strlen($fromString);
            $returnString = "";

            for($count = 0; $count < $stringLength; $count++)
            {
                $random = (rand() % $fromStrLen);
                $random = rand(0,$fromStrLen);
                $returnString .= substr($fromString, $random, 1);
            }

            return $returnString;
        }
    }

This class is useful anytime you need a random string of any length. All the functions are called staticly, so no need to create an object just call the class.

Example 1:
Create a random string of 12 lowercase-alphabet characters

print RandomString::generateRandomAlphaString(12);

Example 2:
Create a random string of 12 uppercase-alphabet characters

print RandomString::generateRandomAlphaString(12, 'upper');

Example 3:
Create a random string of 12 mixed-case-alphabet characters

print RandomString::generateRandomAlphaString(12, 'mixed');

Example 4:
Create a random string of 12 number characters

print RandomString::generateRandomNumericString(12);

Example 5:
Create a random string of 12 number characters or lower-case alphabet characters

print RandomString::generateRandomAlphaNumericString(12);

Example 6:
Create a random string of 12 number characters or upper-case alphabet characters

print RandomString::generateRandomAlphaNumericString(12, 'upper');

Example 7:
Create a random string of 12 number characters or mixed-case alphabet characters

print RandomString::generateRandomAlphaNumericString(12, 'mixed');

Example 8:
Create a random string of 12 number characters, mixed-case alphabet characters, or special characters

print RandomString::generateRandomStringWithAll(12);

This class will pretty much fill all your random string needs. Feel free to use it if you like, or make suggestions to changes, to make it better.

3 Comments more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...