Programming

Java: An Introduction to a Notorious Object-Oriented Language

tl;dr (too long; didn’t read) – Java is infamously difficult according to many programmers, but it’s good to know. The next post delves into terminology and concepts. // Continue if you want to read more. /* Java is notorious as being one of the most difficult to learn for beginner programmers, but don’t worry! This just means when you grasp it, the other object-oriented languages such as C# (Microsoft’s take on Java) or C++ will be a snap to pick up. It’s like learning Latin before you learn Spanish or French! Now, in no way am I saying Java was the first language, because it was probably (I may be wrong here) Assembly or some low-level language and you’ll worry about that if you have to take “Fundamentals of Computer Systems” or require binary/assembly code in whatever it is you’re doing such as x86; however, we’re not learning a low-level language, we’re learning a “high-level language.” The reason Java is considered a high-level language is because of the way it interacts with the system. Not only does it have its own compiler (think of it as a big translator that pre-builds programs for now) and “garbage collector” (which automates memory management) but it also has a virtual environment in which it is run, making it universally available among the operating systems. These are all reasons it’s favorable to have some idea how to code in Java, even if you’ll be writing mostly Javascript or C#, etc. In the next posts we’ll discuss what a class is, what a method and its different types are, what a variable and its different types/scopes are, and how they all fit together to create an instantiated entity or “object.” */

Read more

Track Referer and Entry Page with a Cookie

I found this simple script on the internet by Ammon Johns. He was nice enough to share it as long as we give credit. His script was originally to track a referer. It sets a “referrer” cookie which you can pull into any document using the php code <?php echo $_COOKIE[‘referrer’] ?>. I hope that helps someone, it took me forever to figure it out. There is a way to pull the information with javascript too something like “document.cookie.referrer or some such, but i’m no expert in javascript yet. I wanted to track the entry page as well because I had another script assigning a variable of k_wcid (omniture) to any person who came into our site through google’s PPC (Pay Per Click) Adwords campaign. This way we coudl track what site and keywords they came from with the referrer, and what page they landed on, which would also tell us if it was PPC or not.   The following code creates the cookie “URL” which can be called in PHP with <?php echo $_COOKIE[‘URL’] ?> The funny thing about setting and using these cookies is that you set the field with the value of “var=” (“URL=”, or “referrer=” for example)  and then call them withotu the “=”! Dont forget to give me some credit too! // JavaScript Cookie Code // Coding by Ammon Johns // www.webmarketingplus.co.uk // Modified for URL by Alexander Conroy “Geilt” // www.esotech.org – [email protected] // You may not modify or use this code except as stated in at // http://www.webmarketingplus.co.uk/promotions/cookie-tracking.html var cDomain = self.location.hostname; // cDomain becomes hostname www.vitalonehealth.com if(cDomain.indexOf(“.”) < cDomain.lastIndexOf(“.”)){ //Checks the number position of the domainname whcih is www. (4) vs the number position of .com which is 4.  if it is less then… var domainOffset = cDomain.indexOf(“.”)+1  //add 1 to the index number total, so if its 3 then it puts it to 4 cDomain = cDomain.substr(domainOffset); // domain now extracts 4 letters out. } if(document.referrer.indexOf(cDomain)==-1 && document.referrer!=”” && document.cookie.indexOf(“referrer=”)==-1){ var expDays = 90; var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); var refdate = new Date(); document.cookie = “referrer=” + escape(document.referrer); } if(document.cookie.indexOf(“URL=”)==-1){ var expDays = 90; var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); document.cookie = “URL=” + escape(document.URL); } var allCookies = document.cookie; var cPos = allCookies.indexOf(“referrer=”); if(cPos != -1){ var cdstart = cPos + 9; var cdend = allCookies.indexOf(“;”, cdstart); if(cdend == -1) cdend = allCookies.length; var cookieContent = allCookies.substring(cdstart,cdend); cookieContent = unescape(cookieContent); var cdatestart = cookieContent.indexOf(“&&&”, 0); var cdateend = cookieContent.length; var cRefer = cookieContent.substring(0,cdatestart); var cDateRef = cookieContent.substring(cdatestart +2,cdateend) } else{ var cRefer = “No cookie”; var cDateRef = “No cookie”; }

Read more

PHP Option Select Menu Generator Function – Dropdown Menu

http://snipplr.com/view/43100/php-option-select-menu-generator-function–dropdown-menu/

Read more

Code Ascetic – SEO Tracking in 4 Lines of Code

I am going to save you all a bunch of headaches and time staring into the sky for the SEO God’s to grant you an effective way to track the conversion from traffic to lead. It is as simple as a few lines of PHP code. I am sure there are equivalents in the other server side scripting languages that someone can kindly post in a reply. Here is the Snippet. if (is_null($_COOKIE[‘referer’])) setcookie(“referer”, $_SERVER[‘HTTP_REFERER’]); if (is_null($_COOKIE[‘entrance’])) setcookie(“entrance”, $_SERVER[‘PHP_SELF’]); What does this do? It checks if there is a current cookie for both the website passed Referer value and if there is a landing page value. If not, it grabs the referer from the last website the person has been too (including organic google search) and the page that they landed on, for instance, index.htm or /affordable-health-insurance/ becomes the value of $_COOKIE[‘entrance’] An easy way to check how your cookies are being set is through this simple PHP Script. You can save a file as test.php and include only the following code: print_r($_COOKIE); This prints the cookies you have set in order. Note: Most Dynamic CMS will already have a bunch of Cookies set that you can take advantage of once you figure out their name value through that smalls cript. The key to web programming is being able to do the most actions with the least amount of code and processing cycles / memory usage. This is similar to being an code ascetic, the more you can go without will bring you to a state of efficiency not many can achieve.  Keep this method for your records! Keep this ideology in your coding! Funny, I reduced this from 6 lines to 4 when i redid this Website and copied content over 😉

Read more

Why “GET” Can Be a Problem Over “Post”

This has to do purely with browser limitations. I recently encountered a major error using a Dialer management system that uses massive GET requests that fill the header with every parameter. I tried to create a custom query and save it so that I would be able to use it again. Unfortunatly it would return a error in internet connection page. I called up the company to find out what was going on. As usual, it is a problem they have never seen before and I was able to create an issue that can be a major problem to them in the future. The problem was that You can only have up to 2083 characters in the url for IE. I was trying to create a query with about 40 states included as well as other custom fields in their search feature. Knowing this it makes me wonder why even bother with the lack of security of PHP GET over POST. POST is cleaner, easier to manage and limits what the user can do without clear access. This makes for better programming and the necessity to check for problems and redundancies. The solution is simply resolved by switching to firefox which allows for longer URL Strings in the Header…but their software was “built” for IE. Ah well.  

Read more