Monday, December 27, 2010
Saturday, December 25, 2010
Php tit bits
1. open php.ini file located under XAMPP/xampp/php/php.ini
2. set the following attributes
display_errors
Log_errors
error_log
Global key word:
The variable declared global will be accessible through out the entire php and also other php files that are included . it will also be accessible inside function provided they are resolved using the global keyword
Session variables not getting propagated ?
Add the following line of code in all phps
session_start();
Understanding $this :
The methods in a class can be invoked in two modes one by creating an instance for the class and invoking the method through that instance. The second way would be invoke the method in static mode with out creating an instance. $this represents the instance on which the method is invoked. similar to the "this" key word in java. The difference being as shown in the example below
Class A {
variable data = "class A";
method tellClass() {
echo data;
}
}
Class B {
variable data = "class B";
method callClassA () {
A:: tellClass()
}
}
objB = new ClassB();
objB-> callClassA();
Output :
ClassB
Static keyword
1 . static variable can be accessed without creating an instance using the scope resolution :: operator
2. non static variables cannot be accessed using the scope resolution operation they can onlybe accessed by creating instances
3. non static functions can be accessed using the scope resolution operator. though this is deprecated. will raise E_STRICT warning
4. $this cannot be used inside a static function to resolve other static /non static variables. use 'self' ex self::$bar. Note self can only be used to access static properties you will not be able to access non static properties using 'self' keyword
5. You will have to use $this or the self keyword to access class level properties directly using the variable name will not resolve to the class level property.
6. non static variables cannot be accessed inside a static function
7. you will not be able to access static properties using an instance of the class. Note: though this will not result in an error the value will be empty/null
8. you can call a static function using an instance of the class.
Access Specifiers in PHP :
public : methods/properties can be accessed from all the classes through an instance.
protected : methods/properties can be accessed within the same class and also all the inherited classes
private: methods/properties can be accessed only with the same class
String :
1. single quoted string does not print the values of the variable in them. It will also print special characters as they are .
ex $data = "CAT";
echo ' this is the $data';
ouput:
this is the $data
2. double quoted stings prints the values of the variables in them. they also interpret escape sequences.
3. heredoc - <<<"label" : this is similar to double quoted string except that it prints ' " ' without any need for escape sequence
4. nowdoc - <<<'label' : this is similar to single quoted string except that it prints "' " without a need for escape sequence.
Thursday, November 11, 2010
Understanding Callback functions in Jquery
Callback and Functions
A callback is a function that is passed as an argument to another function and is executed after its parent function has completed. The special thing about a callback is that functions that appear after the "parent" can execute before the callback executes. Another important thing to know is how to properly pass the callback. This is where I have often forgotten the proper syntax.
Callback without arguments
For a callback with no arguments you pass it like this:
$.get('myhtmlpage.html', myCallBack);
Note that the second parameter here is simply the function name (but not as a string and without parentheses). Functions in Javascript are 'First class citizens' and so can be passed around like variable references and executed at a later time.
Callback with arguments
"What do you do if you have arguments that you want to pass?", you might ask yourself.
Wrong
The Wrong Way (will not work!)
$.get('myhtmlpage.html', myCallBack(param1, param2));
This will not work because it calls
myCallBack(param1, param2)
and then passes the return value as the second parameter to $.get()
Right
The problem with the above example is that myCallBack(param1, param2) is evaluated before being passed as a function. Javascript and by extension jQuery expects a function pointer in cases like these. I.E. setTimeout function.
In the below usage, an anonymous function is created (just a block of statements) and is registered as the callback function. Note the use of 'function(){'. The anonymous function does exactly one thing: calls myCallBack, with the values of param1 and param2 in the outer scope.
$.get('myhtmlpage.html', function(){
myCallBack(param1, param2);
});
param1 and param2 are evaluated as a callback when the '$.get' is done getting the page.
source :http://docs.jquery.com/Tutorials:How_jQuery_Works#jQuery:_The_Basics
Converting Jquery to DOM
var nodeObjsArray = $(".NodeClass").get();
The above script will fetch all DOM objects whose class name matches "NodeClass"
Note that it returns an array. To fetch each DOM element you will have to iterate through it. This hold good even if there is only one match you would get an array
with one DOM object in it
var nodeObjs = $(".NodeClass").get(0);
same as
var nodeObjs = $(".NodeClass")[0]
In the above script we are fetching the DOM object directly unlike the previous case
Converting DOM to JQuery Object
var domObj = document.getElementById("elementID");
var jqObj = $(domObj );
Reference
http://api.jquery.com/get/
Wednesday, November 10, 2010
Thursday, October 28, 2010
Setting up Env For PHP
1. Install Eclipse
2. In Eclipse help>InstallNewSoftware in the drop down select "All Available sites" -> under "programing language" select "Php Development tool" and install
3. In Eclipse click new > others > php project
4. In Eclipse click on the project created new > php file
XAMPP Settings :
1. Download XAMPP from http://www.apachefriends.org/en/xampp.html
2. Install XAMPP
3. Start XAMPP. Click on Start button against the apache on the XAMPP panel
4. It should show a green indicator with text "running" in it
5. try to hit this link http://localhost/ using the browser a XAMPP local home page should load if not your there is some problem with you apache start up
Apache start up error
1. If you do not see a green indicator with text "running" or you are unable to load the XAMPP home page using the http://localhost/ . your ports may be blocked.
2. Click on the Port-Check button on the panel. and see if port 80 is free or being used by some application. If its not free terminate the application using the port
3. Restart XAMPP and try step 1
XAMPP Config :
1. Navigate to the following installation path \xampp\apache\conf and open the httpd.conf search for attribute "DocumentRoot" and replace the path with the workspace path where the project resides . This has to be replaced at two places in the same file
Access Denied Error :
1. Navigate to the following installation path \xampp\apache\conf and open the httpd.conf search for attribute "DocumentRoot" and replace the path with the workspace path where the project resides . This has to be replaced at two places in the same file
Setting up Password for MySql:
1. Start MySql using the button on the XAMPP panel .
2. Click on the Admin button on the XAMPP panel.
3. Create Database using the phpMyAdmin ui
4. Set password for the DataBase created
5. close the browser . Navigate to the following installation path \xampp\phpMyAdmin
6. open file config.inc.php and change the following
'auth_type'] = 'http';
'AllowNoPassword'] = false;
provide the user/pwd details in the same file
7. Restart MySql and Apache using the XAMPP panel and click on the Admin button .
8. Provide the log in credentials to log into the database
Tuesday, October 19, 2010
Serializable
Class A {
public string data;
}
Class B implements Serializable{
public ClassA objClassA
public String str
}
Class C {
//set values in objClassA
//set values in str
// tries to serialize class B
//print task complete
}
Output :>
java.io.NotSerializableException: Class A
----------------------------------------------------------------
Code :>
Class A {
public string data;
}
Class B implements Serializable{
public ClassA objClassA
public String str
}
Class C {
//set values in str
// tries to serialize class B
//print task completed
}
Output :>
Task complete
Tuesday, October 12, 2010
Monday, October 11, 2010
Jtest
# For "License Server Port", enter 2002 (it's the default)
Monday, September 6, 2010
manga pachadi
Raw magoes (skin removed and cut into 2 inch cubes ) – 4 cups
Jaggery – 1 cup
Salt – 1/4 tea spoon
Peanut oil – 1 tea spoon
Dry red chillies – 2
Coriander leaves – 1 Sprig
Mustard + Jeera seeds – 1/2 tea spoon
Asfoetida – 1 pinch
How to make it ?
In a thick bottomed vessel put the raw mango pieces and add 1/2 cup of water and cover it with a lid. Let it cook for 7- minutes or until the entire thing becomes mushy. Sprinkle the salt over it and add the jaggery now. In one or two minutes the jaggery will melt nicely and get blended with the mango. Give a taste and if u want it more sweeter add little more jaggery. Switch off the stove.
In a thick bottomed small vessel add the peanut oil and once hot add the mustard and jeera seeds. Once they pop add the asfoetida, curry leaves and split red chillies. Mix in low flame for 10 – 12 seconds and pur it over the mango mix. Mix well and serve with rotis or rice and dal.
Thursday, July 8, 2010
Log 4j appender issue
The above error results when you have the same appender type referenced multiple time in the same log 4j prop/xml file or across mulitiple prop/xml files.
Thursday, June 10, 2010
Vegetable Biriyani
Ingredients :
Set 1:
Onion cut long - 1
tomato - 1
ginger - 1tbs
garlic - 1tbs
garam masala - 2 tbs
cinnamon for flavour
green chilly - 3
ghee
Set 2:
carrot chopped long - 2
cauliflower - half a cup
peas - half a cup
toasted bread - 2
potato - 1
coriander - for flavour fine chopped
Set 3
rice - 2 cups
wash the rice in water ; drain the water and let it dry for 15 mins.
Steps :
1. fry Set 1 in ghee
2. Add set2 and fry
3. Add rice and then water . rice to water ration is 1 :1.5
4. pressure cook for one whistle
5. before serving add toasted bread crumbs.
courtesy MOM :-)
Tuesday, June 8, 2010
Chicken Gravy
2. Now, Heat the oil in a pan & add fennel seeds,cinnamon,cloves & bay leaves fry till gloden brown.
3. Then, add the chopped onion & fry till golden brown & add chopped tomato now and cook the tomato till the oil comes seperate from onion & tomato.
4. And now, add the marinated chicken,1/2 cup water & cook it for 15 to 20 minutes in medium heat.
5. After that add the coriander powder,chilli powder & curd.Cook this for 10 minutes in medium heat.
6. Garnish the chicken with the coriander leaves & keep the flame in low heat & close the pan for 5 minutes till the oil comes seperate from the chicken.
7. Serve the chicken with Rice,Roti,Puri & Paratha.
Courtesy :http://deepa-cooks.blogspot.com
Thursday, June 3, 2010
Ant Build Script
<property name="component.version" value="1.0.01"/>
<property name="src.dir" value="./src"/>
Referring to a property
This prints the value set in the property dist.dir
<echo>${dist.dir}</echo>
Deleting a dir
<delete dir="${dist.dir}" verbose="false"/>
Creating a dir
<mkdir dir="${dist.dir}"/>
Thursday, May 27, 2010
Test pad : Regex
. | . | Any single character. Example: h.t matches hat, hit, hot and hut. |
[ ] | [ ] | Any one of the characters in the brackets, or any of a range of characters separated by a hyphen (-), or a character class operator (see below). Examples: h[aeiou][a-z] matches hat, hip, hit, hop, and hut; [A-Za-z] matches any single letter; x[0-9] matches x0, x1, …, x9. |
[^] | [^] | Any characters except for those after the caret “^”. Example: h[^u]t matches hat, hit, and hot, but not hut. |
^ | ^ | The start of a line (column 1). |
$ | $ | The end of a line (not the line break characters). Use this for restricting matches to characters at the end of a line. Example: end$ only matches “end” when it’s the last word on a line, and ^end only matches “end” when it’s the first word on a line. |
\< | \< | The start of a word. |
\> | \> | The end of a word. |
\t | \t | The tab character. |
\f | \f | The page break (form feed) character. |
\n | \n | A new line character, for matching expressions that span line boundaries. This cannot be followed by operators ‘*’, ‘+’ or {}. Do not use this for constraining matches to the end of a line. It’s much more efficient to use “$”. |
\xdd | \xdd | “dd” is the two-digit hexadecimal code for any character. |
\( \) | ( ) | Groups a tagged expression to use in replacement expressions. An RE can have up to 9 tagged expressions, numbered according to their order in the RE. The corresponding replacement expression is \x, for x in the range 1-9. Example: If \([a-z]+\) \([a-z]+\) matches “way wrong”, \2 \1 would replace it with “wrong way”. |
* | * | Matches zero or more of the preceding characters or expressions. Example: ho*p matches hp, hop and hoop. |
? | ? | Matches zero or one of the preceding characters or expressions. Example: ho?p matches hp, and hop, but not hoop. |
+ | + | Matches one or more of the preceding characters or expressions. Example: ho+p matches hop, and hoop, but not hp. |
\{count\} | {count} | Matches the specified number of the preceding characters or expressions. Example: ho\{2\}p matches hoop, but not hop. |
\{min,\} | {min,} | Matches at least the specified number of the preceding characters or expressions. Example: ho\{1,\}p matches hop and hoop, but not hp. |
\{min,max\} | {min,max} | Matches between min and max of the preceding characters or expressions. Example: ho\{1,2\}p matches hop and hoop, but not hp or hooop. |
\’ | ‘ | Matches either the expression to its left or its right. Example: hop\’hoop matches hop, or hoop. |
\ | \ | “Escapes” the special meaning of the above expressions, so that they can be matched as literal characters. Hence, to match a literal “\”, you must use “\\”. Example: \<> |
Tit-Bits
Synchronizing Hashmap :
private Map values = Collections.synchronizedMap(new HashMap());
----------------------------------------------------------------------------------------
Generate Random numbers :
The below code generates random numbers under 100
Random randomGenerator = new Random();
for (int idx = 1; idx <= 10; ++idx){
int randomInt = randomGenerator.nextInt(100);
log("Generated : " + randomInt);
}
----------------------------------------------------------------------------------------
Generate Random String:
String correlationId = RandomStringUtils.randomAlphabetic(8)
----------------------------------------------------------------------------------------
Class.java
TestClass obj = new TestClass();
Class objClass = obj.getClass();
String strPackage = objClass.getPackage().getName();
The Class obj has various methods to fetch info on the list of methods, constructors , member variables.
Wednesday, May 26, 2010
cropping
- open pic
- click on the crop button available on the tool box
- or right click on the image, click on tool > Transform Tools > crop
- select the section of the image and double click
- right click the image click on scale image
- select the scale ratio
- save image
Monday, May 24, 2010
Log 4j filter
The log4j filter allows you to filter out logger statements based on the textual message in the logger . its helpful if you want to get rid of few logger statements for debugging purpose
ex :
<filter class="org.apache.log4j.varia.StringMatchFilter">
<param name="StringToMatch" value="=================" />
<param name="AcceptOnMatch" value="false" />
</filter>
this would not log the below log statement in the console
LOGGER.debug("The XML is ================="+ swRequestXml.toString());
Friday, May 21, 2010
Reading from Properties File
InputStream is = null;
try {
is = DataSource.class.getClassLoader().getResourceAsStream(
"LocalDS.properties");
objDSProp = new Properties();
objDSProp.load(is);
String Value = objDSProp.getProperty("key");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Wednesday, May 19, 2010
List Of Oracle System Tables
System Table | Description |
---|---|
ALL_ARGUMENTS | Arguments in object accessible to the user |
ALL_CATALOG | All tables, views, synonyms, sequences accessible to the user |
ALL_COL_COMMENTS | Comments on columns of accessible tables and views |
ALL_CONSTRAINTS | Constraint definitions on accessible tables |
ALL_CONS_COLUMNS | Information about accessible columns in constraint definitions |
ALL_DB_LINKS | Database links accessible to the user |
ALL_ERRORS | Current errors on stored objects that user is allowed to create |
ALL_INDEXES | Descriptions of indexes on tables accessible to the user |
ALL_IND_COLUMNS | COLUMNs comprising INDEXes on accessible TABLES |
ALL_LOBS | Description of LOBs contained in tables accessible to the user |
ALL_OBJECTS | Objects accessible to the user |
ALL_OBJECT_TABLES | Description of all object tables accessible to the user |
ALL_SEQUENCES | Description of SEQUENCEs accessible to the user |
ALL_SNAPSHOTS | Snapshots the user can access |
ALL_SOURCE | Current source on stored objects that user is allowed to create |
ALL_SYNONYMS | All synonyms accessible to the user |
ALL_TABLES | Description of relational tables accessible to the user |
ALL_TAB_COLUMNS | Columns of user's tables, views and clusters |
ALL_TAB_COL_STATISTICS | Columns of user's tables, views and clusters |
ALL_TAB_COMMENTS | Comments on tables and views accessible to the user |
ALL_TRIGGERS | Triggers accessible to the current user |
ALL_TRIGGER_COLS | Column usage in user's triggers or in triggers on user's tables |
ALL_TYPES | Description of types accessible to the user |
ALL_UPDATABLE_COLUMNS | Description of all updatable columns |
ALL_USERS | Information about all users of the database |
ALL_VIEWS | Description of views accessible to the user |
DATABASE_COMPATIBLE_LEVEL | Database compatible parameter set via init.ora |
DBA_DB_LINKS | All database links in the database |
DBA_ERRORS | Current errors on all stored objects in the database |
DBA_OBJECTS | All objects in the database |
DBA_ROLES | All Roles which exist in the database |
DBA_ROLE_PRIVS | Roles granted to users and roles |
DBA_SOURCE | Source of all stored objects in the database |
DBA_TABLESPACES | Description of all tablespaces |
DBA_TAB_PRIVS | All grants on objects in the database |
DBA_TRIGGERS | All triggers in the database |
DBA_TS_QUOTAS | Tablespace quotas for all users |
DBA_USERS | Information about all users of the database |
DBA_VIEWS | Description of all views in the database |
DICTIONARY | Description of data dictionary tables and views |
DICT_COLUMNS | Description of columns in data dictionary tables and views |
GLOBAL_NAME | global database name |
NLS_DATABASE_PARAMETERS | Permanent NLS parameters of the database |
NLS_INSTANCE_PARAMETERS | NLS parameters of the instance |
NLS_SESSION_PARAMETERS | NLS parameters of the user session |
PRODUCT_COMPONENT_VERSION | version and status information for component products |
ROLE_TAB_PRIVS | Table privileges granted to roles |
SESSION_PRIVS | Privileges which the user currently has set |
SESSION_ROLES | Roles which the user currently has enabled. |
SYSTEM_PRIVILEGE_MAP | Description table for privilege type codes. Maps privilege type numbers to type names |
TABLE_PRIVILEGES | Grants on objects for which the user is the grantor, grantee, owner, or an enabled role or PUBLIC is the grantee |
TABLE_PRIVILEGE_MAP | Description table for privilege (auditing option) type codes. Maps privilege (auditing option) type numbers to type names |
Monday, May 17, 2010
Linked
Linked
What is linked ?
Linked is a downloadable html page which can be set as your browsers home page and customized to dock all your favorites (links to webpages) . Linked enables you to arrange the links in a hierarchical manner for quick access. This is much faster than navigating through your favorites in your browser.
How do I install it ?
To install linked all you will have to do is download the Linked.zip file available in the download section. Place it on the folder of your choice and set the Linked.html file as your home page in your browser.
How Do I Add Folders ?
Open the ‘data’ folder and open one dataset1.xml (dataset2.xml,dataset3.xml can also be used as per your requirement). Add the below tag to create a new folder. Provide unique id for each folder. Provide the name for the folder .
How Do I Add Links under my folder ?
Quick Access to Google :
Clicking on the Linked image on the page will directly take you to Google search page
Linked Quick search :
Enter your search text in the text box provided under the Linked image to do a quick google search
What Linked Cannot do :
You will not be able to dynamically add links to your xmls. There is no provision to add links programmatically . Every time you need to add a new link you will have to edit the xmls.
Compatibility :
Works fine on IE and Mozilla . Has not been tested on other browsers
Known Issues :
On IE you will have to disable security pop up blocker to ensure smooth usage
Download :