Monday, September 30, 2013

What's the difference between 'git pull' and 'git fetch'?

  • When you use pull, Git tries to automatically do your work for you. It is context sensitive, so Git will merge any pulled commits into the branch you are currently working in. pull automatically merges the commits without letting you review them first. If you don’t closely manage your branches you may run into frequent conflicts.
  • When you fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository. However, it does not merge them with your current branch. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use merge.

git rebase vs git merge

Short Version

  • Merge takes all the changes in one branch and merge them into another branch in one commit.
  • Rebase says I want the point at which I branched to move to a new starting point
So when do you use either one?

Merge

  • Let's say you have created a branch for the purpose of developing a single feature. When you want to bring those changes back to master, you probably want merge (you don't care about maintaining all of the interim commits).

Rebase

  • A second scenario would be if you started doing some development and then another developer made an unrelated change. You probably want to pull and then rebase to base your changes from the current version from the repo.

Sunday, September 29, 2013

using github + eclipse to pull code

eGit doesn't know, which remote branch you want to pull from. If you create your local branch based on a remote tracking branch, then the key is generated automatically. Otherwise you have to create it yourself:
branch.master.merge=refs/heads/master
branch.master.remote=origin
where master stands for the branchname, in the key it's your local branch, in the value it's the branch in the remote repository. Place that in the repository-specific configuration file%repositorypath%\.git\config
As for the terms:
  • merge: join two or more development histories together
  • fetch: download objects and refs from another repository
  • pull: fetch from and merge with another repository or local branch
  • sync: allows you to compare 2 branches
In general, I urge you to read eGit user guide, where you can get even better understanding of Git and eGit. It can be found at http://wiki.eclipse.org/EGit/User_Guide

Thursday, September 26, 2013

Enabling log4j logging in Hibernate

Hibernate 3 has integrated with slf4j logging which demands an additional step in getting Hibernate’s log4j logs. This is important because in debug mode, Hibernate logs the SQL query strings and the bind variable values. The steps to configure for capturing the log4j logs from Hibernate are below:
1. Place log4j, slf4j-api and slf4j-log4j jars in the classpath. I am using log4j-1.2.15.jar, slf4j-api-1.5.3.jar and slf4j-log4j12-1.5.3.jarfiles.
2. Now configure the log4j.properties (or XML) file and place it in your classpath. A sample properties file content is provided below. This will print all the logs on to the console. Configure a file appender if you want the logs to be writtwen to a file.
Sample log4j.properties:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
log4j.logger.org.hibernate=debug
log4j.logger.org.springframework=debug
log4j.logger.org.hibernate.hql.ast.AST=info
log4j.logger.org.hibernate.SQL=trace
log4j.logger.org.hibernate.type= trace
log4j.logger.org.hibernate.tool.hbm2ddl=warn
log4j.logger.org.hibernate.hql=debug
log4j.logger.org.hibernate.cache=info
log4j.logger.org.hibernate.jdbc=debug

You are now good to go :) Happy logging !!

Oracle - what is tnsnames

When clients want to connect to an Instance, they need to know where
the connectionrequest should be made, and how it should be made. The TNSNAMES.ORA file is a text file,located on each client machine, which gives the client these two crucial pieces of information.

Strictly speaking, clients don’t connect directly to an Instance at all. Instead, theyconnect to a Listener process, which knows where to establish the connection to the Instance on the client’s behalf. Therefore, a large part of the “where” information in TNSNAMES.ORA is related to identifying the machine on which the Listener is running, and the port it is listening on. There is also an element which specifies which particular Instance the client wishes to connect to, since a single Listener process can be listening on behalf of many Instances.

The “how” information in the TNSNAMES.ORA file relates mainly to the networking protocol by which the client wishes to connect to the Instance (should it be TCP/IP,SPX/IPX and so on). There is also a part which informs the Listener whether the client isseeking a dedicated or shared server connection.

http://www.scribd.com/doc/58113083/Oracle-what-is-tnsnames

Monday, September 23, 2013

ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

Symtompts of the Problem:
---------------------------

Whenever you try to conenct to database by providing SYS user name and password it retuens error.
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

Cause of The Problem:
--------------------

This is because of the parameter O7_DICTIONARY_ACCESSIBILITY settings to FALSE. 

Access to dictionary objects is restricted to the users with the system privileges SYSDBA and SYSOPER. Connecting as SYSDBA gives a user unrestricted privileges to perform any operation on a database or the objects within a database. Data dictionary objects is under SYS schema and is protected by O7_DICTIONARY_ACCESSIBILITY to FALSE settings.

Workaround Example:
---------------------

1)Try to connect by user sys without sysdba privilege.

SQL> conn sys/a
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER

Warning: You are no longer connected to ORACLE.

2)Connect as sysdba and change O7_DICTIONARY_ACCESSIBILITY
SQL> conn / as sysdba
Connected.

SQL> SHOW PARAMETER O7_DICTIONARY_ACCESSIBILITY
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
O7_DICTIONARY_ACCESSIBILITY boolean FALSE

SQL> ALTER SYSTEM SET O7_DICTIONARY_ACCESSIBILITY=TRUE scope=spfile;
System altered.


3)Since O7_DICTIONARY_ACCESSIBILITY is static parameter restart is necessary.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup

ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 2019288 bytes
Variable Size 109051944 bytes
Database Buffers 50331648 bytes
Redo Buffers 6369280 bytes
Database mounted.
Database opened.

4)Now connect as sys with only password.

SQL> conn sys/a
Connected.

SQL> show parameter O7_DICTIONARY_ACCESSIBILITY
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
O7_DICTIONARY_ACCESSIBILITY boolean TRUE

5)Though you are SYS user but you have not currently have SYSDBA privilege. So, you can't do SYSDBA privilege tasks.

SQL> shutdown immediate;
ORA-01031: insufficient privileges

SQL> show user
USER is "SYS"


Caution:
-----------

Oracle Strongly recommends not to use O7_DICTIONARY_ACCESSIBILITY to TRUE.

http://arjudba.blogspot.com/2008/05/ora-28009-connection-as-sys-should-be.html

Lost Oracle SYS and SYSTEM password?

If your administration is as good as anybodies, you are bound to loose the not-so-frequently used password for the SYS and SYSTEM users of oracle. Here are a few ways I found to re-set those passwords:
Method 1: SQLPLUS (Tested on AIX Oracle 9.2.0.1.0)
Log into the database server as a user belonging to ‘dba’ [unix ] or ‘ora_dba’ [windows ] group , typically ‘oracle’, or an administrator on your windos machine. You are able to log into Oracle as SYS user, and change the SYSTEM password by doing the following:
$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Apr 5 15:32:09 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> show user

USER is "SYS"

SQL> passw system
Changing password for system
New password:
Retype new password:
Password changed
SQL> quit

Next, we need to change the password of SYS:
$ sqlplus "/ as system"
SQL*Plus: Release 9.2.0.1.0 - Production on Mon Apr 5 15:36:45 2004

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SP2-0306: Invalid option.
Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
where   ::= [/][@] | /
Enter user-name: system
Enter password:

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL> passw sys
Changing password for sys
New password:
Retype new password:
Password changed
SQL> quit
You should now be able to log on the SYS and SYSTEM users, with the passwords you just typed in.
Method 2: Creating pwd file (Tested on Windows Oracle 8.1.7)
  1. Stop the Oracle service of the instance you want to change the passwords of.
  2. Find the PWD###.ora file for this instance, this is usuallly located atC:\oracle\ora81\database\, where ### is the SID of your database.
  3. rename the PWD###.ora file to PWD###.ora.bak for obvious safety reasons.
  4. Create a new pwd file by issuing the command: 
    orapwd 
    file=C:\oracle\ora81\database\PWD###.ora password=XXXXX
    where ### is the SID and XXXXX is the password you would like to use for the SYS and INTERNAL accounts.
  5. Start the Oracle service for the instance you just fixed. You should be able to get in with the SYS user and change other passwords from there.

Create/replace trigger in Squirrel

You should unload "sqlparam" plugin in SQuirrel, after that it won't ask you to fill values for ":paramName" variables

http://stackoverflow.com/questions/4333267/create-replace-trigger-in-squirrel

How to Grant and Revoke privileges in Oracle


Data Control Language (DCL) Statements

Data Control Language Statements are used to grant privileges on tables, views, sequences, synonyms, procedures to other users or roles.

The DCL statements are

GRANT          :Use to grant privileges to other users or roles.
REVOKE       :Use to take back privileges granted to other users and roles.

Privileges are of two types :

  • System Privileges
  • Object privileges

System Privileges are normally granted by a DBA to users. Examples of system privileges are CREATE SESSION, CREATE TABLE, CREATE USER etc.

Object privileges means privileges on objects such as tables, views, synonyms, procedure. These are granted by owner of the object.

Object Privileges are

ALTER  
Change the table definition with the ALTER TABLE statement.  
DELETE  
Remove rows from the table with the DELETE statement.
Note: You must grant the SELECT privilege on the table along with the DELETE privilege. 
INDEX  
Create an index on the table with the CREATE INDEX statement.  
INSERT  
Add new rows to the table with the INSERT statement.  
REFERENCES  
Create a constraint that refers to the table. You cannot grant this privilege to a role.  
SELECT  
Query the table with the SELECT statement.  
UPDATE  
Change data in the table with the UPDATE statement.  

Note: You must grant the SELECT privilege on the table along with the UPDATE privilege. 

Grant

Grant is use to grant privileges on tables, view, procedure to other users or roles


Examples

Suppose you own emp table. Now you want to grant select,update,insert privilege on this table to other user “SAMI”.

grant select, update, insert on emp to sami;

Suppose you want to grant all privileges on emp table to sami. Then

grant  all on emp to sami;

Suppose you want to grant select privilege on emp to all other users of the database. Then

grant select on emp to public;

Suppose you want to grant update and insert privilege on only certain columns not on all the columns then include the column names in grant statement. For example you want to grant update privilege on ename column only and insert privilege on empno and ename columns only. Then give the following statement

grant update (ename),insert (empno, ename)  on emp to sami;


To grant select statement on emp table to sami and to make sami be able further pass on this privilege you have to give WITH GRANT OPTION clause in GRANT statement like this.

grant select on emp to sami with grant option;



REVOKE


Use to revoke privileges already granted to other users.

For example to revoke select, update, insert privilege you have granted to Sami then give the following statement.

revoke select, update, insert on emp from sami;

To revoke select statement on emp granted to public give the following command.

revoke select on emp from public;

To revoke update privilege on ename column and insert privilege on empno and ename columns give the following revoke statement.

revoke update, insert on emp from sami;

Note :You cannot take back column level privileges. Suppose you just want to take back  insert privilege on ename column then you have to first take back the whole insert privilege and then grant privilege on empno column.

ROLES


A role is a group of Privileges. A role is very handy in managing privileges, Particularly in such situation when number of users should have the same set of privileges.


For example you have four users :Sami, Scott, Ashi, Tanya in the database. To these users you want to grant select ,update privilege on emp table, select,delete privilege on dept table. To do this first create a role by giving the following statement

create role clerks

Then grant privileges to this role.

grant select,update on emp to clerks;
grant select,delete on dept to clerks;

Now grant this clerks role to users like this

grant clerks to sami, scott, ashi, tanya ;

Now Sami, Scott, Ashi and Tanya have all the privileges granted on clerks role.

Suppose after one month you want grant delete on privilege on emp table all these users then just grant this privilege to clerks role and automatically all the users will have the privilege.

grant delete on emp to clerks;

If you want to take back update privilege on emp table from these users just take it back from clerks role.

revoke update on emp from clerks;


To Drop a role

Drop role clerks;

LISTING INFORMATION ABOUT PRIVILEGES


To see which table privileges are granted by you to other users.

SELECT * FROM USER_TAB_PRIVS_MADE

To see which table privileges are granted to you by other users

SELECT * FROM USER_TAB_PRIVS_RECD;

To see which column level privileges are granted by you to other users.

SELECT * FROM USER_COL_PRIVS_MADE

To see which column level privileges are granted to you by other users

SELECT * FROM USER_COL_PRIVS_RECD;

To see which privileges are granted to roles

SELECT * FROM USER_ROLE_PRIVS;

How to check the privileges assigned to a role

-- select all the role name and granted role

select *
from role_role_privs
order by 1;


-- select all the roles and their privilages

select *
from role_sys_privs
where ROLE = 'TABQ'
order by 1;

------------------------------------------------------

-- show all object privilages in a role

select *
from role_tab_privs
where role = 'TABQ';

https://forums.oracle.com/thread/2140697?start=0&tstart=0

Preparing for the Security Clearance Interview

By John V. Berry, Esq., www.berrylegal.com
You have completed your e-QIP / SF-86 and you are waiting to be interviewed in the next step of the investigative process in order to obtain your Top Secret security clearance.  This is often referred to as the Personal Interview or Personal Subject Interview stage.  Given that this next step in the process is very important to your ultimate security clearance review, it is important to go in as prepared as possible. The interview process will usually occur a short time following the submission and review of the completed security clearance materials by the investigator. 
Security clearance investigators will review and confirm the information that the individual has supplied in the security clearance submission.  For instance, the investigator will speak with former supervisors, neighbors, co-workers, in addition to references to get a full background of the individual seeking the clearance prior to the interview. The investigator assigned to the case will also check with law enforcement agencies in areas where an individual has lived and will have reviewed other important background information.  When this review is complete, the investigator will then generally contact an individual for their personal interview. 
Preparation for the Interview
It is important for an individual to prepare for their interview with the investigator.  As mentioned above, the investigator will have reviewed the individual's submissions prior to the interview and will have identified any significant areas of concern prior to the meeting.  In our experience, generally, the individual involved will have some idea about potential areas of concern that might be brought up in the interview and thus will generally have time to prepare.
Preparation for the personal interview, as to these areas of potential concern, is a must.  For instance, if there is a recent arrest on your record, the individual should be prepared to fully explain the incident to the investigator and toprovide the relevant details.  This is just one example.  Another example is where the individual has had an alcohol related offense.  In that type of situation, the individual should go into the interview fully prepared to discuss the incident and what steps the person has taken to avoid the issue from happening again.
If your case involves known security concerns then it is also important to gather any important and relevant documents, especially those that can be helpful in explaining or mitigating the potential security concerns at issue in advance.  We advise going over these issues, in advance, with counsel so that the interview will go smoothly. 
The Personal Interview
The interview stage itself tends to last usually 1-2 hours, although different cases can result in varying times for the interview process.  Most times, there is just one investigator assigned for the personal interview, but there can be two investigators in some cases. If there are two investigators usually one of them will be assigned to ask the majority of questions, while the other may ask some follow up questions.
It is recommended that an individual bring a copy of his/her SF-86 / e-QIP application for the questions that will be discussed.  An investigator will generally go over an individual's security materials thoroughly, but may also have other questions not covered on the security forms such as issues related to illegal downloading of materials, viewing of inappropriate materials and other types of misconduct which could raise security concerns.
As mentioned above, it is important to be prepared, in advance, to address the most likely areas of concern.  It is also important to be as responsive as possible on the areas of concern raised by an investigator during the interview process.  This is clearly not the time for an individual to be defensive or to refuse to answer an investigator's questions.  Doing so may delay the individual's ability to obtain a security clearance (at best) and in some situations may result in the denial of a security clearance application.
Post Interview
When finished with the first interview, many times investigators may have follow up questions.  They may conduct these follow up interview questions by telephone or in person.  We advise clients to be responsive to such requests and to attempt to provide investigators enough information to conclude their investigation successfully.  An individual does not want an investigator to give up on a clearance application and conclude that the security concerns are too significant to overcome. 
Conclusion
When undergoing your background investigation for your security clearance, it is very important to be prepared for the interview stage of the process.  It can make the difference between obtaining and being denied your security clearance.  Our law firm represents federal employees and contractors in these types of security clearance matters and can be contacted at www.berrylegal.com.

Sunday, September 22, 2013

What good technology podcasts are out there?

Yes, Podcasts, those nice little Audiobooks I can listen to on the way to work. With the current amount of Podcasts, it's like searching a needle in a haystack, except that the haystack happens to be the Internet and is filled with too many of these "Hot new Gadgets" stuff :(
Now, even though I am mainly a .NET developer nowadays, maybe anyone knows some good Podcasts from people regarding the whole software lifecycle? Unit Testing, Continous Integration, Documentation, Deployment...
So - what are you guys and gals listening to?

Please note that the categorizations are somewhat subjective and may not be 100% accurate as many podcasts cover several areas. Categorization is made against what is considered the "main" area.

General Software Engineering / Productivity

.NET / Visual Studio / Microsoft

jQuery

Java / Groovy

Ruby / Rails

Web Design / JavaScript / Ajax

Unix / Linux / Mac / iPhone

System Administration, Security or Infrastructure

General Tech / Business

Other / Misc. / Podcast Networks