http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Friday, November 29, 2013
Monday, September 23, 2013
CSV file download code
Details later,
<?php
if(!empty($_GET['file'])){
$foo = "some value,another value,last value";
file_put_contents("File1.csv",$foo);
@ob_end_clean();
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=File1.csv");
header("Cache-control: private");
header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$new_length = filesize("File1.csv");
echo $foo;
}else{
echo "<a href='?file=1'>Click here</a>";
}
?>
<?php
if(!empty($_GET['file'])){
$foo = "some value,another value,last value";
file_put_contents("File1.csv",$foo);
@ob_end_clean();
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=File1.csv");
header("Cache-control: private");
header('Pragma: private');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$new_length = filesize("File1.csv");
echo $foo;
}else{
echo "<a href='?file=1'>Click here</a>";
}
?>
Wednesday, September 18, 2013
Javascript objects
In JavaScript, almost everything is an object. All primitive types except
Another way for creating objects in javascript,
Constructor - function are methods and it's constructor,
function f1(){
//function itself is a constructor of object
}
Confused?Let's see below,
null
and undefined
are treated as objects. They can be assigned properties and they have all characteristics of objects. Javascript is object based programming language (Prototype-based programming). First time when I heard, JS is OO programming, I was surprised and can't find and class, interface, etc such keywords. Later, I found, it's different. See below,var jsObj = new Object();
jsObj.property1 = "Value1";
jsObj.property2
= "Value2";
That's how we create object and use properties. Alternative way to accessing properties,myCar["property1"] = "Value1";myCar["property2"] = "Value2";
Aren't they associative arrays?Yes, you are right!Javascript Objects are sometimes called associative arrays.Another way for creating objects in javascript,
var obj = { 'property1': "Value1",
'property1': "Value2"};// property1 can be number, string or identifier
Methods in javascript,Constructor - function are methods and it's constructor,
function f1(){
//function itself is a constructor of object
}
Confused?Let's see below,
function Jsobject(pro1, pro2, pro3) {
this.pro1 = pro1;
this.pro2 = pro2;
this.pro3 = pro3;
}
this above means current object (instance). Like this in java and any other object oriented programming.var myvar = new Jsobject
("Value1", "Value2", "Value3");
Isn't myvar is object?So, isn't function constructor?Alternate way to access properties,myvar.pro1
= "Value1";
It can be chained like,Vehicle.scooter.numWheels = 2;
What about methods?See below,var objMethods = {
method1: function(params) {
//body of method here
}
}
;
You can assign method to an variable. Suppose you defined function with name method1 then you can assign as below,this.method =
method1;
As always more coming soon. Keep coming here.jQuery background
Before starting learning jQuery, it's helpful to know some following javascript tricks,
Anonymous Functionsg
- Anonymous functions are nameless function (function having no name).
- Anonymous functions are executed as soon as they are downloaded by browser (if they are not within another function).
- They are in 2 types.
First type,
(function(){
//some cool js stuff here.
});
Second type (with passing arguments),
(function(args){
//some cool js stuff here.
})(args);
//Above last line will pass args. This looks odd having args 2 times. But learning this way is helpful.
Eg.
(function(args){
alert(args);
})("hi");
Above function will alert
hi
Other interesting stuff of a
nonymous functions in javascript,
We can pass anonymous function as argument, like we pass int, string, etc.
Eg,
function acceptAnonymousFunction(annonymousFunc) { // some code here
('javascript!'); }
annonymousFunc
(function(arg) { alert('Hello '+ arg); }); // alerts 'Hello
acceptAnonymousFunction
!'
javascript
Got it! If not re-read it carefully, you will understand it.
Assigning javascript function as variable,
var myfunc = function(args)
{
//functionality of myfunc here
}
myfunc(args); // this is calling of myfunc
Above code will do exactly same as,
function myfunc(args){
//functionality of myfunc goes here
}
More interesting stuff...coming soon!!Keep reading.
Monday, September 16, 2013
jQuery Tutorial
jQuery Basic
*Features of Progressive enhancement and Unobtrusive JavaScript -
- jQuery is free and open source.
- jQuery is library of common tasks, re-usable code.
- jQuery is cross browser - It means it runs in most of browsers.
- Using jQuery you can easily create Progressive enhancement and Unobtrusive JavaScript*.
- It simplified javascript programming.
- It's easy to learn jQuery.
- jQuery avoids copy/pasting (re-inventing wheel) tasks.
- You can download jQuery from
ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js. You can even use following code in your site,
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Using above code, you can avoid server load as jQuery will be downloaded from googleapis.com CDN (content delivery network)
- jQuery simplifies common tasks like, Ajax, DOM element selections, traversal and manipulation, event handling, popup, and also extensible, etc.
jQuery official sites are -
*Features of Progressive enhancement and Unobtrusive JavaScript -
- Functionality should be separate from presentation. In other words, Javascript code should be separate from html/ css code.
- Graceful degradation - If browser doesn't support some feature, javascript should not show error. It degrades gracefully.
- Progressive enhancement - Similar to above. If browser doesn't support, it shouldn't support extra wow animated effects, but shows basic HTML. But in new browsers with greater bandwidths, it shows full featured, wow effect animations. But there should be alternate way to use it for other browsers. (eg. gmail shows basic HTML version during slow connection or in old browsers).
How to add Javascript in sugarcrm?
Suppose you want to add cases_custom.js in cases module,
Open
custom/modules/Cases/metadata/editviewdefs.php file,
Add following code at right place in above file,
'includes'=> array(
array('file'=>'custom/modules/Cases/cases_custom.js'),
),
Now create file cases_custom.js inside custom/modules/Cases/metadata/cases_custom.js
That's it. Now write javascript inside, cases_custom.js
Thursday, August 29, 2013
Jquery virus
Use google CDN or any authenticated source, because fake jquery may contain virus.
(A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet).
Use jquery.com or jqueryui.com. They are real sites. You can use google CDN for various javascript libraries.
Here is list of libraries with URLs of google,
https://developers.google.com/speed/libraries/devguide#jquery
jquerys.com is fake (see extra s), jquery.com is real site. Beware of such sites.
(A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet).
Use jquery.com or jqueryui.com. They are real sites. You can use google CDN for various javascript libraries.
Here is list of libraries with URLs of google,
https://developers.google.com/speed/libraries/devguide#jquery
jquerys.com is fake (see extra s), jquery.com is real site. Beware of such sites.
Monday, August 26, 2013
Jquery UI
Jquery UI draggable exampleExample one of drag
- Second example of drag
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
Friday, August 16, 2013
Jquery , Apache, MySql, PHP http://jampcoaching.com/ is lunched
http://jampcoaching.com/ is launched.
Syllubus of PHP-
1. Introduction to php
2. Installing php
3. Variables, data types and arithmetic expressions
4. Looping , condition (if, else and other).
5. Array
6. Functions
7. Classes in php
8. Working with files / directories
9. Form handling in php.
10. State maintaining
11. Session, cookies
12. Database functions
a) Connection
b) Inserting rows
c) Fetching rows
d) Updating rows
Syllubus of PHP-
1. Introduction to php
2. Installing php
3. Variables, data types and arithmetic expressions
4. Looping , condition (if, else and other).
5. Array
6. Functions
7. Classes in php
8. Working with files / directories
9. Form handling in php.
10. State maintaining
11. Session, cookies
12. Database functions
a) Connection
b) Inserting rows
c) Fetching rows
d) Updating rows
Subscribe to:
Posts (Atom)