PPT Macro for Formatting multiple slides


Dear All,

Many times we come across situation in which we need to format 100's of slides withing specified amount of time, and doing it manually is really not a smart way thats where macro comes in picture.

Below is sample macro I have written for formatting active slides :

I hope you know how to run macros ;) else you can always take help from Google!!!!!!


Dim myvar As Slide
Dim myvar1 As Shape


For Each myvar In ActivePresentation.Slides
For Each myvar1 In myvar.Shapes


With myvar1
.Left = 50
.Top = 71
.LockAspectRatio = msoFalse
.Height = 410
.Width = 624
.Line.Visible = msoTrue
.Line.ForeColor.RGB = RGB(255, 0, 0)
.Line.Weight = 0.5

 
End With

Next
Next


Above macro will simple change formatting for all active slides ;)

Hope you enjoyed!!

Best Regards,
Girish

Dynamic Column width in BI Publisher

Dynamic Column width in BI Publisher

This has been a complex task to assign width of column dynamically in BI Publisher. This means number of columns is not fixed and they will come dynamically from XML and we want width of the columns to be distributed equally or in some ratio. Combined width of all columns assigned dynamically will be taken up from the width that we assign to that particular column. If there is only single column coming from XML then it will take up all width. If there are multiple columns then the width will be equally distributed or we can define in which ratio it should be distributed.

How it is done ?

Here is an example of how it can be done in BI Publisher.

1. Load Below XML:


< ?xml version="1.0" encoding="utf-8"?>
< TestScoreTable>
< LIST_COLUMNS>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>Current Terms< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>2 - 30 Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>31 - 60 Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>61 - 90 Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< LIST_COLUMN>
< LIST_COLUMN_HEADING>91 - Plus Days< /LIST_COLUMN_HEADING>
< /LIST_COLUMN>
< /LIST_COLUMNS>
< TestScores>
< TestCategory>Mathematics< /TestCategory>
< TestScore width ="15">
< TestScoreRange>0-20< /TestScoreRange>
< NumofStudents>30< /NumofStudents>
< /TestScore>
< TestScore width ="10">
< TestScoreRange>21-40< /TestScoreRange>
< NumofStudents>45< /NumofStudents>
< /TestScore>
< TestScore width ="15">
< TestScoreRange>41-60< /TestScoreRange>
< NumofStudents>50< /NumofStudents>
< /TestScore>
< TestScore width ="10">
< TestScoreRange>61-80< /TestScoreRange>
< NumofStudents>102< /NumofStudents>
< /TestScore>
< TestScore width ="15">
< TestScoreRange>81-100< /TestScoreRange>
< NumofStudents>22< /NumofStudents>
< /TestScore>
< /TestScores>
< /TestScoreTable>

2. create below template in BIP.

template in BIP

3. Modify code in template according to below table as shown in image below:

    Text To Display        Code    
  Group:TestScore    < ?for-each:TestScores?>  
  < ?TestCategory?>    < ?TestCategory?>  
  Column Header and Splitting    < ?split-column-header:TestScore?>< ?split-column-width:@width?>< ?TestScoreRange?>  
  Content and Splitting    < ?split-column-data:TestScore?> < ?NumofStudents?>  
  End:TestScore    < ?end for-each?>  


BI Publisher

4. Hit Pdf under BI Publisher and your pdf will be like shown below:


BI Publisher
Here you can see that we have defined width of each column in XML like .
If we remove one or two columns and see output then we will see that width of these columns has been distributed in others.

BI Publisher

Sending mail with attachment in JAVA

Sending mail with attachment in JAVA

The JavaMail API is a set of abstract APIs that model a mail system. The API provides a platform independent and protocol independent framework to build Java technology based email client applications. The JavaMail API provides facilities for reading and sending email. The package defines classes that are specific to mail systems based on internet standards such as MIME, SMTP, POP3, and IMAP.
Jar files required:

1. mail.jar that you can download here

Java Source code Sending Mail


package mail;

import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.PasswordAuthentication;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;


public class sendMail {


static String username = "abcdefgh"; //replace this with a valid username
static String password = "password"; //replace this with a valid password

public static void main(String[] args)throws Exception{

try{


String host = "mail.xyz.com"; //replace this with a valid host
int smtpPort = 000; //replace this with a valid port
String from = "testmail@mail.com"; //replace this with a valid email id
String to = "findmail@mail.com"; //replace this with a valid email id
String fileAttachment1 = "D://file1.txt"; // file to attach
String fileAttachment2 = "D://file2.pdf"; // file to attach

Properties props = System.getProperties();
props.put("mail.smtp.host", host); // Setup mail server
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", smtpPort);
Session session = Session.getDefaultInstance(props); // Get session
MimeMessage message = new MimeMessage(session); // Define message
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Find Attachment"); // create the subject
MimeBodyPart messageBodyPart = new MimeBodyPart(); //fill message
messageBodyPart.setText("Welcome to JAVA Family"); // create the message part
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart); // Part two is attachment

messageBodyPart = new MimeBodyPart();
DataSource source1 = new FileDataSource(fileAttachment1);
messageBodyPart.setDataHandler(new DataHandler(source1));
messageBodyPart.setFileName(fileAttachment1.substring(4, fileAttachment1.length()));
multipart.addBodyPart(messageBodyPart);

messageBodyPart = new MimeBodyPart();
DataSource source2 = new FileDataSource(fileAttachment2);
messageBodyPart.setDataHandler(new DataHandler(source2));
messageBodyPart.setFileName(fileAttachment2.substring(4, fileAttachment2.length()));
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
}
}

How to take ScreenShot in iOS ?

How to take ScreenShot in iOS ?

Sometimes requirement arises in iPhone/iPad app that how we get screenshot of a particular UI part. So this captured screenshot can be sent as attachment to authorities via mail or can be written on to photo library.

MyImage Subclass of UIImage

We have to make subclass of UIImage that is MyImage and we are going to implement some extra methods inside it to get screen shot of a particular UI part. so customized MyImage Class code is given below.

MyImage.h File


@interface UIImage (MyImage)
+ (UIImage*)imageFromView:(UIView*)view;
+ (UIImage*)imageFromView:(UIView*)view scaledToSize:(CGSize)newSize;
+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize;
@end

MyImage.m File


#import < QuartzCore/QuartzCore.h>
#import "MyImage.h"
@implementation UIImage (MyImage)
+ (void)beginImageContextWithSize:(CGSize)size
{
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
if ([[UIScreen mainScreen] scale] == 2.0) {
UIGraphicsBeginImageContextWithOptions(size, YES, 2.0);
} else {
UIGraphicsBeginImageContext(size);
}
} else {
UIGraphicsBeginImageContext(size);
}
}

+ (void)endImageContext
{
UIGraphicsEndImageContext();
}

+ (UIImage*)imageFromView:(UIView*)view
{
[self beginImageContextWithSize:[view bounds].size];
BOOL hidden = [view isHidden];
[view setHidden:NO];
[[view layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
[self endImageContext];
[view setHidden:hidden];
return image;
}

+ (UIImage*)imageFromView:(UIView*)view scaledToSize:(CGSize)newSize
{
UIImage *image = [self imageFromView:view];
if ([view bounds].size.width != newSize.width ||
[view bounds].size.height != newSize.height) {
image = [self imageWithImage:image scaledToSize:newSize];
}
return image;
}

+ (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize
{
[self beginImageContextWithSize:newSize];
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
[self endImageContext];
return newImage;
}
@end

TakeScreenShot Method

This is method, put inside your class where-ever you need to take screenshot Here
1) filePath is Document Directory path where your screenshot will be stored finally.
2) customizedView is your View , whose screenshot you want to capture.


-(void)takeScreenShot{
NSArray *arrPaths =
NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString *strDocumentPath = [arrPaths objectAtIndex:0];
NSString *filePath = [strDocumentPath stringByAppendingPathComponent:@"screenshot.png"];

UIImage *img = [UIImage imageFromView:customizedView];
//imgSignature.image = img;
NSData *imgData = UIImageJPEGRepresentation(img, 0.0);
[imgData writeToFile:filePath atomically:YES];
}

screen shot method

Send Email on Startup and Shutdown Process on Linux Server

Send Email on Startup and Shutdown Process on Linux Server

It is always nice to have notification when a server reboots, especially when you are on vacation, away from the office, or just hanging around! In order to send an email on reboot, we can easily create a cron job to run on reboot. This means for a single reboot the Administrator will receive two emails. This solution will not send out an email if the system loses power, however an email will still be sent on reboot. This should indicate to the Administrator that something went wrong with the shutdown. The tips below are for a RedHat based system but should be similar in other architectures.
First thing we need is to create a new script "NotifyEmail"
Paste the following code into that document .


#!/bin/sh
EMAIL="example@example.com"
RESTARTSUBJECT="["`hostname`"] - System Startup"
SHUTDOWNSUBJECT="["`hostname`"] - System Shutdown"
RESTARTBODY="This is an automated message to notify you that "`hostname`" started successfully.
Start up Date and Time: "`date`
SHUTDOWNBODY="This is an automated message to notify you that "`hostname`" is shutting down.
Shutdown Date and Time: "`date`
LOCKFILE=/var/lock/subsys/NotifyEmail
RETVAL=0

# Source function library.
. /etc/init.d/functions

stop()
{
echo -n $"Sending Shutdown Email: "
echo "${SHUTDOWNBODY}" | mutt -s "${SHUTDOWNSUBJECT}" ${EMAIL}
RETVAL=$?
if [ ${RETVAL} -eq 0 ]; then
rm -f ${LOCKFILE}
success
else
failure
fi
echo
return ${RETVAL}
}
start()
{
echo -n $"Sending Startup Email: "
echo "${RESTARTBODY}" | mutt -s "${RESTARTSUBJECT}" ${EMAIL}
RETVAL=$?
if [ ${RETVAL} -eq 0 ]; then
touch ${LOCKFILE}
success
else
failure
fi
echo
return ${RETVAL}
}
case $1 in
stop)
stop
;;
start)
start
;;
*)
esac
exit ${RETVAL}

Save the document by CTRL+O (To Write) and then press CTRL+X (To exit the Editor)
First, we need to make it executable:


chmod u+x NotifyEmail

Now we want to set this up to run at start up and shut down. Copy the script from your home directory to the init.d directory.


cp NotifyEmail /etc/init.d/

Last thing we do is set this up to run automatically by configuring it via chkconfig.


chkconfig --levels 3 NotifyEmail on

The code goes into a file under /etc/init.d
Then you go into /etc/rc.d folder and edit rc.local file. There you add:
Code:


/etc/init.d/NotifyEmail start

Also make a file called rc.local_shutdown in /etc/rc.d/ folder. In that file you add:
Code:


/etc/init.d/NotifyEmail stop

Now using these steps you will receive two mails during startup and shutdown process

Alternative Simple Way for Email Alert on Reboot:

Edit your crontab:


crontab –e

Add the following:


@reboot echo "Server has restarted "`hostname` | mail -s "System Restart" your@email.address

Now using these simple steps you will receive mail whileserver reboot.

Control File in DBMS

Control File in DBMS

The Control File of the database is a binary file that contains database information such as the database name, data about the database log files and data files, timestamp of database creation, tablespace name, checkpoint information and backup information. Database can't open without a Control file.
Getting information of current control file in use:


SQL>SHOW PARAMETER control_files;
SQL>SELECT * FROM v$controlfile;
SQL>SELECT * FROM v$controlfile_record_section;

MULTIPLEXING THE CONTROL FILE USING SPFILE

Let we had two control file control01 and control02 in our database. We are going to multiplex control03 in our database.


SQL>ALTER SYSTEM SET CONTROL_FILES='$HOME/ORADATA/U01/control01.ctl'
'$HOME/ORADATA/U01/control02.ctl','$HOME/ORADATA/U01/control03.ctl' SCOPE=spfile;
SQL>shutdown immediate;

Copy the existing control file with new name control03.ctl on defined path of spfile parameter so that it is available on the os level.

$cp $HOME/ORADATA/U01/control01.ctl $HOME/ORADATA/U01/control03.ctl

Control files can be multiplexed up to eight times. The Oracle server maintains all files listed in spfile parameter when instance is started.

SQL>startup

MULTIPLEXING THE CONTROL FILE USING PFILE

SQL>create pfile from spfile;
SQL>shutdown immediate;

Copy the existing control file with new name control03.ctl

$cp $HOME/ORADATA/U01/control01.ctl $HOME/ORADATA/U01/control03.ctl

Open the pfile and add a new control file control03.ctl and its path in CONTROL_FILES parameter.

SQL>startup;

CONTROL FILE BACKUP

Because the control file records the physical structure of the database so it's an important part of oracle database. It's important to make a backup of control file.

SQL>ALTER DATABASE BACKUP CONTROLFILE TO '/tmp/control_file.bkp';

We can also make backup of control file to a trace file. This trace can contains a script to recreate a control file. Trace file created in UDUMP directory.


SQL>ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/tmp/create_control_file.sql'

Moving ORADATADirectory to another location in Oracle DataBase

Moving ORADATADirectory to another location in Oracle DataBase

Database files are stored in ORACLE_BASE\oradata\DB_NAME\ If you want to move the oradata directory to another location or directory then the minimum required steps are as follow

Step 1:


Creation of tracecopy of the Control file

SQL>ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

The Default location of tracecopy is USER DUMP destination. If you want to find the USER DUMP Destination then use
the following statement

SQL> SHOW PARAMETER USER_DUMP_DEST;

Step 2:

SQL>CREATE PFILE FROM SPFILE;

Step 3:

SQL>SHUTDOWN IMMEDIATE;

Step 4:

Move the ORADATA directory to another location or to the new drive.

Step 5:

SQL>SHUTDOWN IMMEDIATE;

Step 6:

Find the pfile (Default name is initSID.ora).Open the pfile and change the value of CONTROL_FILE parameter to the new location of oradata directory.

Step 7:

SQL>CREATE SPFILE FROM PFILE;

Step 8:

SQL>sqlplus / as sysdba SQL>stratupnomount;

Step 9:

Edit the trace copy of control file created in Step 1 and change the location of data files and Redo log files. Use this script in mount state to create new control file


CREATE CONTROLFILE REUSE DATABASE "SID_NAME" RESETLOGS FORCE LOGGING ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u02/oradata/SID_NAME/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u02/oradata/SID_NAME/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u02/oradata/SID_NAME/redo03.log' SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
'/u02/oradata/SID_NAME/system01.dbf',
'/u02/oradata/SID_NAME/sysaux01.dbf',
'/u02/oradata/SID_NAME/undotbs01.dbf',
'/u02/oradata/SID_NAME/users01.dbf',
'/u02/oradata/SID_NAME/example01.dbf',
CHARACTER SET WE8MSWIN1252
;

Step 10:

Open the Database
SQL>ALTER DATABASE OPEN;

Virtualization

virtualization:

In computing, virtualization means to create a virtual version of a device or resource, such as a server, storage device, network or even an operating system where the framework divides the resource into one or more execution environments. Even something as simple as partitioning a hard drive is considered virtualization because you take one drive and partition it to create two separate hard drives. Devices, applications and human users are able to interact with the virtual resource as if it were a real single logical resource. The term virtualization has become somewhat of a buzzword, and as a result the term is now associated with a number of computing technologies including the following:


• Storage virtualization: The amalgamation of multiple network storage devices into what appears to be a single storage unit.
• Server virtualization: The partitioning a physical server into smaller virtual servers.
• Operating system-level virtualization: A type of server virtualization technology which works at the operating system
(kernel)layer.
• Network virtualization: Using network resources through a logical segmentation of a single physical network.
• Application virtualization: Also called application service virtualization. Application virtualization is layered on
top of other virtualization technologies, such as storage virtualization or machine virtualization to allow computing
resources to be distributed dynamically in real time.
• Virtualization Software : VMware, Oracle Virtual Box Etc.

ORACLE VIRTUAL Box:

Virtual Box is a cross-platform virtualization application. What does that mean? For one thing, it installs on your existing Intel or AMD-based computers, whether they are running Windows, Mac, Linux or Solaris operating systems. Secondly, it extends the capabilities of your existing computer so that it can run multiple operating systems (inside multiple virtual machines) at the same time. So, for example, you can run Windows and Linux on your Mac, run Windows Server 2008 on your Linux server, run Linux on your Windows PC, and so on, all alongside your existing applications. You can install and run as many virtual machines as you like -- the only practical limits are disk space and memory. VirtualBox is deceptively simple yet also very powerful. It can run everywhere from small embedded systems or desktop class machines all the way up to datacenter deployments and even Cloud environments.