Posts tagged Tools
EzRegAPI OCX Control
0
Here is another Activex Control I have created on the old times of Visual Basic. This time, it easiest the tasks of a programmer to use the registry API functions of Windows.
Visual Basic was one of my preferred languages when I started programming, everybody thought that it was a very slow programming language and, even more, it was not a true programming language. My love for this pseudo-language was so strong that I decided to prove to everybody that, with a bit of tweaking here and there and making use of the DLL libraries, I could speed up the application 10 times more.
And that happened, nevertheless, API programming was not easy to do and if you failed to ‘translate’ the variable types of the function called to that of Visual Basic, you could probably end up with a ‘crash’ or ‘out of memory’ error.
This is why I created these ActiveX Controls, so to help others providing a simpler and already translated code to make use of the API functions without worrying about a crash of their programs.
This is what I wrote back then (remember, I was a new born programmer -script kid)
Well, most of the people I know studying our so-loved Visual Basic language find really hard to learn and very time-consuming the way to implement the power of API functions into VB programs. Even for the most simple thing is a time-consuming operation: find and insert necessary functions, constants, and then know exactly the steps to do in order to use the functions appropriately. It is true that VB6 environment provides some templates and that you can create your own to do the job, but sometimes those templates have to be re-shaped to suit the needs of a new project.
That’s why I have started a series of ActiveX controls that will help not only beginners but to all those lazy programmers that, like me, doesn’t like to spend too much time doing research/re-shape and just want to design and code like maniacs.
How to use
The download zip package has a well written help file. You will find everything you need in it.
Download
|
|
download: EzRegAPI OCX Control (203.05KB) added: 12/01/2010 clicks: 752 |
Tweet this! SWFUpload_0_0. Error HTTP Status: 403 Solved
0
SWFUpload is a client-side file upload tool originally developed by Vinterwebb.se. It uses a combination of Flash and JavaScript to provide file upload functionality beyond what the basic browser provides with the <input type=”file” /> tag.
The main features that SWFUpload provides are:
- The ability to select multiple files in the file browser dialog.
- AJAX-style uploading without a page refresh.
- Upload progress events.
- Namespaced classes compatible with other JavaScript libraries (i.e., jQuery, Prototype, etc.).
- Flash 9 and Flash 10 support. (Flash 8 support dropped in version 2.2.0)
SWFUpload is different from other Flash based upload tools because of the philosophy behind its design. SWFUpload gives developers control by leaving the UI in the browser (as much as possible). Developers can use XHTML, CSS, and JavaScript to tailor the upload UI to the needs and style of their site. Upload status updates are made through a set of simple JavaScript events. The developer uses these events to update the webpage as the file upload progresses.
How to use it
I am not going to explain how to use it, if any of you are interested on it, SWFUpload guys have developed a very good site explaining its full functionality.
The problem
After successfully installing the component on one of my projects and working amazingly good on the local computer, when I uploaded the project to the server where I contracted the hosting, suddenly I had an error: SWFUpload_0_0. Error HTTP Status: 403.
I google to find a solution to my problem and found tons of people having the same issue and the answers where always the same. For example:
“You are getting a 403. Which means “forbidden”. This is something on the web server that you’ll have to figure out.SWFUpload doesn’t save the file. It just uploads it to your upload_url (upload.php). You need to add PHP code that saves the file. In PHP the uploaded file is found in $_FILE["Filedata"] by default.”
Say what? I looked at my server’s configuration, checked folder permissions, reviewed my JS and PHP code… NOTHING. Then I thought it was something wrong with server POST Payload checks. Normally, this security configuration is disabled by default on Apache Servers but my provider ‘could’ possibly had this security check on. I had to try and…
Solution
I solved the issue by creating an .htaccess file and writing the following in it:
SetEnvIfNoCase Content-Type “^multipart/form-data;” “MODSEC_NOPOSTBUFFERING=Do not buffer file uploads”
Hope this also works for those having the same issue.
Happy New Year BTW!
Tweet this! eyeOS a ‘very close’ Web Operating System
0I would like to talk to you about an open source Web application that I have followed since its beginnings: eyeOS. This application started with the goal to become a true Web Operating System and now the guys call it Open Source Cloud Computing’s Web Desktop. Even though the idea of having the system files on a server and have ‘dumb’ clients is not new, these guys have created a great tool and nowadays they even work in conjunction with the IT monster IBM.
Maybe the dreamed future of every System Administrator is near, where they do not need to have certain operating system installed on their computers and everything, every little detail, is managed from a server. Client computers just having a ‘web browser’ and a reliable network bandwidth (most LAN do have it) will reduce enormously companies costs and Microsoft’s pocket
Even though I think is a great tool I dislike their interface (sorry guys), it looks far too much like Windows and I think… that nowadays we could provide a better and more intuitive interfaces for clients. Not everybody is a guru folks and not everybody needs to learn Windows to use a computer. Best days are about to come but meanwhile, congratulations eyeOS.
ScreenShoots
Tweet this! Cookies on Roids -JSON Based
2
Every Web programmer, one day or another, works with cookies. Some of us prefer to use server side cookies, others client cookies, and also both, client and server cookies. On my older blogspot blog, one that I even really care to update everyday as I do with this one, I post one class to work with cookies on the client side and one fellow programmer told me about json cookies. I thought it was a great script and that was because by using JSON (thanks David Crockford again!) encoding we could save objects and arrays of information into our good friends ‘cookies’.
Well, on my last post, I have included a JSON Plugin script to use with JQuery. By making a couple of modifications I have created a Cookie and JSON javascript objects to provide you with the possibility to save objects and arrays on cookies. Both of the objects do not require any other dependency library…
Here is the script:
<br />
var JSON = {<br />
useHasOwn : ({}.hasOwnProperty ? true : false),<br />
pad : function(n) {<br />
return n < 10 ? "0" + n : n;<br />
},<br />
m : {<br />
"\b": '\\b',<br />
"\t": '\\t',<br />
"\n": '\\n',<br />
"\f": '\\f',<br />
"\r": '\\r',<br />
'"' : '\\"',<br />
"\\": '\\\\'<br />
},<br />
encodeString : function(s){<br />
if (/["\\\x00-\x1f]/.test(s)) {<br />
return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {<br />
var c = m[b];<br />
if(c){<br />
return c;<br />
}<br />
c = b.charCodeAt();<br />
return "\\u00" +<br />
Math.floor(c / 16).toString(16) +<br />
(c % 16).toString(16);<br />
}) + '"';<br />
}<br />
return '"' + s + '"';<br />
},<br />
encodeArray : function(o){<br />
var a = ["["], b, i, l = o.length, v;<br />
for (i = 0; i < l; i += 1) {<br />
v = o[i];<br />
switch (typeof v) {<br />
case "undefined":<br />
case "function":<br />
case "unknown":<br />
break;<br />
default:<br />
if (b) {<br />
a.push(',');<br />
}<br />
a.push(v === null ? "null" : JSON.encode(v));<br />
b = true;<br />
}<br />
}<br />
a.push("]");<br />
return a.join("");<br />
},<br />
encodeDate : function(o){<br />
return '"' + o.getFullYear() + "-" +<br />
pad(o.getMonth() + 1) + "-" +<br />
pad(o.getDate()) + "T" +<br />
pad(o.getHours()) + ":" +<br />
pad(o.getMinutes()) + ":" +<br />
pad(o.getSeconds()) + '"';<br />
},<br />
encode : function(o){<br />
if(typeof o == "undefined" || o === null){<br />
return "null";<br />
}else if(o instanceof Array){<br />
return JSON.encodeArray(o);<br />
}else if(o instanceof Date){<br />
return JSON.encodeDate(o);<br />
}else if(typeof o == "string"){<br />
return JSON.encodeString(o);<br />
}else if(typeof o == "number"){<br />
return isFinite(o) ? String(o) : "null";<br />
}else if(typeof o == "boolean"){<br />
return String(o);<br />
}else {<br />
var a = ["{"], b, i, v;<br />
for (i in o) {<br />
if(!JSON.useHasOwn || o.hasOwnProperty(i)) {<br />
v = o[i];<br />
switch (typeof v) {<br />
case "undefined":<br />
case "function":<br />
case "unknown":<br />
break;<br />
default:<br />
if(b){<br />
a.push(',');<br />
}<br />
a.push(JSON.encode(i), ":",<br />
v === null ? "null" : JSON.encode(v));<br />
b = true;<br />
}<br />
}<br />
}<br />
a.push("}");<br />
return a.join("");<br />
}<br />
},<br />
decode : function(json){<br />
return eval("(" + json + ')');<br />
}<br />
};</p>
<p>var Cookie = {<br />
jsonencode : JSON.encode,<br />
jsondecode : JSON.decode,</p>
<p> set : function(name,value,options){</p>
<p> options = this.extend({}, options);</p>
<p> if (value === null) {<br />
value = '';<br />
options.expires = -1;<br />
}<br />
var expires = '';<br />
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {<br />
var date;<br />
if (typeof options.expires == 'number') {<br />
date = new Date();<br />
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));<br />
} else {<br />
date = options.expires;<br />
}<br />
expires = '; expires=' + date.toUTCString();<br />
}</p>
<p> var self = this;</p>
<p> value = options.json ? encodeURIComponent(Cookie.jsonencode(value)):encodeURIComponent(value);</p>
<p> var path = options.path ? '; path=' + (options.path) : '';<br />
var domain = options.domain ? '; domain=' + (options.domain) : '';<br />
var secure = options.secure ? '; secure' : '';</p>
<p> document.cookie = [name, '=', value, expires, path, domain, secure].join('');<br />
},<br />
get : function(name,json){</p>
<p> var cookieValue = null;</p>
<p> if (document.cookie && document.cookie != '') {<br />
var cookies = document.cookie.split(';');<br />
for (var i = 0; i < cookies.length; i++) {<br />
var cookie = this.trim(cookies[i]);<br />
// Does this cookie string begin with the name we want?<br />
if (cookie.substring(0, name.length + 1) == (name + '=')) {<br />
cookieValue = json ? this.jsondecode(decodeURIComponent(cookie.substring(name.length + 1))):decodeURIComponent(cookie.substring(name.length + 1));<br />
break;<br />
}<br />
}<br />
}</p>
<p> return cookieValue;</p>
<p> },<br />
unset: function(name){<br />
Cookie.set(name,'',-1);<br />
},<br />
trim: function( val ) {<br />
return (val || "").replace( /^\s+|\s+$/g, "" );<br />
},<br />
extend: function()<br />
{<br />
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;<br />
if ( typeof target === "boolean" ) {<br />
deep = target;<br />
target = arguments[1] || {};<br />
i = 2;<br />
}<br />
if ( typeof target !== "object" && !isFunction(target) )<br />
target = {};<br />
if ( length == i ) {<br />
target = this;<br />
--i;<br />
}<br />
for ( ; i < length; i++ )<br />
if ( (options = arguments[ i ]) != null )<br />
for ( var name in options ) {<br />
var src = target[ name ], copy = options[ name ];</p>
<p> if ( target === copy )<br />
continue;</p>
<p> if ( deep && copy && typeof copy === "object" && !copy.nodeType )<br />
target[ name ] = this.extend( deep,<br />
src || ( copy.length != null ? [ ] : { } )<br />
, copy );</p>
<p> else if ( copy !== undefined )<br />
target[ name ] = copy;</p>
<p> }<br />
return target;<br />
},<br />
isFunction: function(obj){<br />
return toString.call(obj) === "[object Function]";<br />
}<br />
};<br />
As you can see above, I have included a couple of methods that allow me to extend the options of the object at will (thanks jQuery). I believe that you will find it quite useful to extend its functionality. Any ideas will be highly appreciated.
How to use it
</p>
<p>// Create a cookie with the given name and value and other optional parameters.<br />
//<br />
// session cookie -no json<br />
Cookie.set('the_cookie_name', 'the_value');</p>
<p>// get cookie (no json):<br />
var cv = Cookie.get('the_cookie_name');</p>
<p>// session cookie -json, the value can be an object or an array too<br />
Cookie.set('the_cookie_name', 'the_value', {json:true});</p>
<p>// get the cookie (json)<br />
var cv = Cookie.get('the_cookie_name',true);</p>
<p>// Secured cookie, expiring in 14 days<br />
Cookie.set('the_cookie_name', 'the_value', { expires: 14, path: '/', domain: 'yourdomain.com', secure: true });</p>
<p>// Deleting a cookie<br />
Cookie.unset('the_cookie_name', null);</p>
<p>
DOWNLOAD
|
|
download: Cookies on Roids (2.18KB) added: 01/01/2010 clicks: 774 |
Tweet this! JSON jQuery Plugin
14
I finally got a bit of time and I started playing around with the creation of jQuery plugins and did created a couple of them that I believe all of you will find useful, one of them is a JSON plugin.
As you all know jQuery do not have a JSON encode function. I truly do not know the reason why but to implement it was quite easy -maybe the guys from jQuery thought that it wasn’t really necessary and I agree with them. Most of us use JSON on the server side through PHP or whatever the server tech we use but sometimes, and I repeat, sometimes, we require to develop client applications that by using JSON (thanks David Crockford) we can reduce our server resources and the amount of data transmitted between client and server. But this is a subject that I will treat in the next posts.
Here is the plugin code:
jQuery.JSON = {
useHasOwn : ({}.hasOwnProperty ? true : false),
pad : function(n) {
return n < 10 ? "0" + n : n;
},
m : {
"\b": '\\b',
"\t": '\\t',
"\n": '\\n',
"\f": '\\f',
"\r": '\\r',
'"' : '\\"',
"\\": '\\\\'
},
encodeString : function(s){
if (/["\\\x00-\x1f]/.test(s)) {
return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if(c){
return c;
}
c = b.charCodeAt();
return "\\u00" +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"';
}
return '"' + s + '"';
},
encodeArray : function(o){
var a = ["["], b, i, l = o.length, v;
for (i = 0; i < l; i += 1) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if (b) {
a.push(',');
}
a.push(v === null ? "null" : this.encode(v));
b = true;
}
}
a.push("]");
return a.join("");
},
encodeDate : function(o){
return '"' + o.getFullYear() + "-" +
pad(o.getMonth() + 1) + "-" +
pad(o.getDate()) + "T" +
pad(o.getHours()) + ":" +
pad(o.getMinutes()) + ":" +
pad(o.getSeconds()) + '"';
},
encode : function(o){
if(typeof o == "undefined" || o === null){
return "null";
}else if(o instanceof Array){
return this.encodeArray(o);
}else if(o instanceof Date){
return this.encodeDate(o);
}else if(typeof o == "string"){
return this.encodeString(o);
}else if(typeof o == "number"){
return isFinite(o) ? String(o) : "null";
}else if(typeof o == "boolean"){
return String(o);
}else {
var self = this;
var a = ["{"], b, i, v;
for (i in o) {
if(!this.useHasOwn || o.hasOwnProperty(i)) {
v = o[i];
switch (typeof v) {
case "undefined":
case "function":
case "unknown":
break;
default:
if(b){
a.push(',');
}
a.push(self.encode(i), ":",
v === null ? "null" : self.encode(v));
b = true;
}
}
}
a.push("}");
return a.join("");
}
},
decode : function(json){
return eval("(" + json + ')');
}
};
How to use
Copy and paste the above code onto a file and name it whatever you like, for the sake of the example we will call it jquery.json.js. And then configure your head section like this:
<!-- jquery library (if you dont have it, then download it--> <script language="javascript" src="jquery.1.3.2.js" ></script> <!-- our plugin file --> <script language="javascript" src="jquery.json.js"></script>
That’s it, now we can call our plugin like this:
// test variables
var obj = {json:'this is a test json property',xml:'this is a test xml property'};
var arr = ['A','B of 2 index array','C','D'];
// encoding an object
var a = $.JSON.encode(obj);
alert('json encoded object:'+a);
// decoding an object
var b = $.JSON.decode(a);
alert('json decoded object property:'+b.json);
// encoding an array
a = $.JSON.encode(arr);
alert('json encoded array:'+a);
// decoding the array
b = $.JSON.decode(a);
alert('json decoded array:'+b[1]);
On future posts we will make use of this plugin to show what we can do with it.
Tweet this! Javascript Online Compression Tools
0
When a Web project is finished, it is time to think how to make it better, faster… how to improve user’s experience. One of the most important things is javascript code compression in order to speed up page downloads and there are a couple of tools around that allows us to do it.
I just include three references:
- The Online YUI Compressor – by Mike
- The Online YUI Compressor – by Rodolphe Stoclin
- The Online Javascript Minifier - by Vance Lucas
The Online YUI Compressors
These tools allows us to make use of the famous Yahoo Javascript Compression algorithm. Both of the above references does the same results, there is only a major difference between both: whilst the one created by Mike allows you to paste your script or upload a file to compress, the one created by Rodolphe Stoclin only allows us to upload the file to compress.
The Online Javascript Minifier
This tool can reduce our code by using two different algorithms: the JSMin by David Crockford and the Packer method by Dean Edwards.
Which One to Use?
I personally like those algorithms that do not make any use of the eval function and doesn’t change much the code I program, test, and implement. I think that will only depend of the developer choice.
There is an online tool that help us compare the algorithms. If that helps you to decide which one to use: http://compressorrater.thruhere.net/
Tweet this! Ajax Load -Ajax Loading GIF Generator
0
Who of those of you that use ajax on your projects aren’t looking around the web to find the perfect ‘loading please wait’ GIF for your brand new web application or site? I have to confess that I was one of them. I am not a designer, I can program any web application in a matter of days but when it comes to design… puff… It is the reason why I am always crawling the web for ‘inspiration’.
One of those days crawling I found an online tool created by kath called Ajax Load – Ajax Loading GIF Generator. There you don’t need to worry if you know how to design or not, this simple but very useful tool allows you to select the type of design you want for your ajax loading gif, the foreground and background colors and voilá, your ajax loading gif is ready to download.

For those, like me, without a clue about designing there it is, the Ajax Load – Ajax Loading GIF Generator.
Tweet this! Creating Small Urls with PHP
0
Have you ever wanted to create small URLs like in Twitter? This service is provided by bit.ly and it is the one I normally use for my projects. It allows you to shorten any long URL (ie. http://www.ramirezcobos.com = http://bit.ly/8zivPq -click on it and you will be redirected here) and also gives you click statistiques.
Nevertheless, there are also other providers that allows you to create a small URL on the fly such as tinyurl.com or to.y. If any of you wishes to create small urls through their PHP code here I got a set of functions (using CURL) for you use on your projects:
function getTinyUrl($url){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function getToLyUrl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://to.ly/api.php?longurl='.urlencode($url));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec ($ch);
curl_close ($ch);
return $data;
}
Usage
$smallURL = getTinyUrl('http://www.ramirezcobos.com');
echo $smallURL; // will display the small URL
Extras
I include the following function too just in case, as I recommend you to check if URLs are in correct format before using the above functions.
function getParsedUrl($url)
{
$parsed_url = parse_url($url);
if (!isset($parsed_url['scheme']) or $parsed_url['scheme'] != 'http'){
echo 'Unsupported URL sheme given, please just use "HTTP".';
exit();
}
if (!isset($parsed_url['host']) or $parsed_url['host'] == ''){
echo 'Invalid URL given!';
exit();
}
$host = $parsed_url['host'];
$host .= (isset($parsed_url['port']) and !empty($parsed_url['port'])) ? ':'.$parsed_url['port'] : '';
$path = (isset($parsed_url['path']) and !empty($parsed_url['path'])) ? $parsed_url['path'] : '/';
$path .= (isset($parsed_url['query']) and !empty($parsed_url['query'])) ? '?'.$parsed_url['query'] : '';
return 'http://' . $host . $path;
}
Tweet this! 

Try to register and click again. Sometimes the plugin i have to count downloads do fail.There was an issue with the cache, solved by […] 6 days ago