Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Archive for January, 2012

Create .zip files with JavaScript dynamically

Tuesday, January 31st, 2012 by Servage
The JavaScript library JSZip provides you with the ability to generate .zip files dynamically. This way you can send lots of data to a user in a convenient and bandwidth-saving way. With JavaScript becoming more and more powerful, and the amount of data handled by JavaScripts increasing every day, this is a great way to communicate with the user. Most users generally accept zip files from trusted sites - assuming that your users trust your site ;-) It's really easy to create a .zip file. Check out this sample code: var zip = new JSZip(); zip.add("Hello.txt", "Hello World\n"); img = zip.folder("images"); img.add("smile.gif", imgData, {base64: true}); content = zip.generate(); location.href="data:application/zip;base64,"+content; Creating zip files in the browser with JavaScript also ...

Get the location for your visitor with PHP

Saturday, January 28th, 2012 by Servage
It's fairly simple to figure out where your visitors come from. There's a great database available at ipinfodb.com which you can access via PHP scripts for example. This gives your the possibility to find out where visitors are coming from (as long as they are not hiding behind a proxy). Check out this script (source): function detect_city($ip) { $default = 'Hollywood, CA'; if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') $ip = '8.8.8.8'; $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip); $ch = curl_init(); ...

Sending SMS to cellphones from your website

Friday, January 27th, 2012 by Servage
smsgatewayDo you know how easy it is to send SMS from your website? It can be integrated in minutes and offers a wide range of advantages for you and your users. It could be used to send information, notifications, updates and more to your users. It's only limited by your imagination. Servage Hosting offers an SMS gateway that you can use to send SMS with. You simply add SMS credits to your Servage account and integrate the SMS sending functionality on your site. This could for example be done within a short time with the ready-to-run scripts available in the control panel. This article features two examples of how to use the Servage SMS gateway with ...

Internationalize your WP plugins

Tuesday, January 24th, 2012 by Servage
If you're developing Wordpress plugins, remember that sharing them is really great for anyone facing similar needs as you. However, sharing plugins only makes sense, if the plugins have a decent quality. That meant obeying to general coding standards, documenting source code etc. This not only helps others understand your code, but also yourself (have you ever tried understanding an own, poorly written, and undocumented piece of code a year after you wrote it?). In addition to general standards and good practices, you should consider internationalizing your plugin as well. That doesn't mean you have to translate it into various languages, but merely that you use functions which prepare your plugin ...

Switch to a Virtual Private Server today – only $8/month!

Monday, January 23rd, 2012 by Servage
Sweden's best uptime again with 99,9% Read more in InternetWorld 03/11. Do you want you own server? Do you need special software? Are you tired of performance problems? Are you just curious? Well, there are many good reasons to get an own virtual private server. The price is definitely also one of them! Consider this offer from Servage. It's pretty much the same cost as a shared webhosting account! RAM Memory: 256 MB Traffic: 100 GB Diskspace: 50 GB Full root access Power On/Off from CP Backup (snapshots) ACPI shutdown from CP Console access from CP Check out the plans. Cloud Based Server Virtualization The TotalCloud server virtualization offering is based on a modular setup where the servers are ...

PHP Development Part 2 – Functions

Wednesday, January 18th, 2012 by Servage
Hi again, please enjoy the second part of our PHP Development guide for beginners. This part is dedicated to functions. Functions are small pieces of code, that perform a calculation, check or anything you want. The reason why these pieces of code are made available as functions, is so you can re-use the same functionality again and again, without reprogramming the same thing over and over. Consider a simple example: You want to display the following text for each user logged in to your website: "You are from England", where England is a variable depending on the individual user. In that case, you could consider a function like this: function write_country($country_name) { return ...

Supercharge media elements on your website

Tuesday, January 17th, 2012 by Servage
Are you using videos online? Check out Popcorn to supercharge your media development! The developer describes: Popcorn.js utilizes the native HTMLMediaElement properties, methods and events, normalizes them into an easy to learn API, and provides a plugin system for community contributed interactions. Popcorn has dozens of plugins for common services and APIs, ranging from Twitter, to Maps, to media events, and more. But if it doesn’t do what you need right now, you can write your own plugins quickly and easily. Tested + Community Supported With over 1400 unit tests, popcorn.js is put through the paces at every release. A result of many iterations, popcorn.js achieved its 1.0 milestone thanks to the ...

Audio decoding with JavaScript

Sunday, January 15th, 2012 by Servage
Have you ever considered audio decoding in JavaScript? Maybe it's not the first intended usage, but ofmlabs' codecs are definitely interesting for relevant web projects. The developers describe their two plugins: Web browsers are becoming more and more powerful, and new APIs like the Web Audio API and Audio Data API are making the web an ever more interesting and dynamic place. At ofmlabs we are invested in improving the state of audio on the web, and with JSMad showed that decoding audio purely in JavaScript is possible thanks to these APIs and the hard work of browser makers and spec authors. And now we've done it again. Introducing ...

PHP Development Part 1 – Variables

Saturday, January 14th, 2012 by Servage
The Servage support team seems a lot of requests involving programming issues. Mostly involving the PHP language. Many of the issues could easily be resolved with more programming knowledge, so I'll try to spread the basic concepts of PHP programming a little further, by publishing a little PHP course. The first part will be about the absolute basics on how to get started with PHP. Consider the following example PHP file: <?php $job_title = 'Developer'; $annual_income = 60000; $income_per_month = $annual_income / 12; echo 'Monthly income for a '.$job_title.' is '.$income_per_month; ?> We will go through this line by line. The <?php statement declares that this file is a PHP file. This is necessary for the system to know, ...

JavaScript made better with CoffeeScript

Thursday, January 12th, 2012 by Servage
CoffeeScript improves your JavaSript-based development experience. The developers describe it: "CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way. The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. You can use any existing JavaScript library seamlessly from CoffeeScript (and vice-versa). The compiled output is readable and pretty-printed, passes through JavaScript Lint without warnings, will work in every JavaScript implementation, ...