For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Saturday, August 30, 2014

Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in

Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in

While connecting with Google gmail via PHP , Java or any other code you may be face this error and get the message as listed below:
"Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX"

To overcome this problem logon your gmail and set permission via this link:
https://www.google.com/settings/security/lesssecureapps

After that you will be able to login via any programming languages.




Share:

Thursday, August 14, 2014

Rotate any Div in jquery

Rotate any Div in html jquery.
==========================



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Multirotation test</title>
        <script type="text/javascript" src="../js/jquery-1.6.js"></script>
        <script type="text/javascript" src="jquery.multirotation-1.0.js"></script>
    </head>
    <style type="text/css">
        div{text-align:center;margin:auto}
        div.rotable{background:#00CC66;border:solid 2px #f00;color:#fff;width:10px;height:10px;padding:5px;margin-top:60px;margin-bottom:60px}
    </style>
    <body>
        <div><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
           <div id="img_test" class="rotable">Amit
               
            </div>
            <p id="degs"></p>
        </div>
    </body>
      <script type="text/javascript">
        function plus(id) {
            $(id).rotate({ angle: 10 });
            get(id);
            return false;
        }

        function minus(id) {
            $(id).rotate({ angle: 90, direction: false });
            get(id);
            return false;
        }

        function reset(id) {
            $(id).clearRotation();
            get(id);
            return false;
        }

        function get(id) {
            var degs = $(id).getCurrentDegrees();
            //$('p#degs').html("Current degs: <b>" + degs + "°</b>");
        }
        var ang=1;
        intervalID=setInterval("setRotate('#img_test');",100);
       
        function setRotate(id) {
            $(id).rotate({ angle: 5 });
            get(id);
        }
       
       
    </script>
</html>



HERE IS THE jquery.multirotation-1.0.js CODE:
-----------------------------------------------------------------------

(function($){
    //global array to save the current rotation of the elements
    $.elems_rotation_history = [];

    $.fn.extend({
        clearRotation: function() {
            return this.each(function() {
                //get the element's identifier
                var id = this.id;
                //remove element from array
                $.elems_rotation_history[id] = null;
            });
        },

        getCurrentDegrees: function() {
            var id = this.attr('id');
            if (!$.elems_rotation_history[id]) {
                return 0;
            }
            return degs = $.elems_rotation_history[id].rotation;
        },

        rotate: function(options) {
            //create console
            if (!window.console) console = {};
            console.log = console.log || function(){};
            console.warn = console.warn || function(){};
            console.error = console.error || function(){};

            //set the default values
            var defaults = {
                  angle: 0
                , direction: true
                , speed: 0
                , deg2radians: Math.PI * 2 / 360
                ///debug
                , debug: false
                ///end
            };

            //to access options values use this: options.option_name
            var options = $.extend(defaults, options);

            return this.each(function() {
                //get the element's identifier
                var id = this.id;

                //if there aren't elements and there isn't the element into the array, sets rotation to 0
                if ($.elems_rotation_history && !$.elems_rotation_history[id]) {
                    $.elems_rotation_history[id] = { rotation: 0 };
                }

                //sets the rotation direction
                if (!options.direction) {
                    options.angle = options.angle * (-1);
                }

                //increments angle rotation of the element
                $.elems_rotation_history[id].rotation = (parseInt($.elems_rotation_history[id].rotation) + options.angle) % 360;

                ///debug
                if (options.debug) {
                    console.log("Angle = " + $.elems_rotation_history[id].rotation + " degree");
                }
                ///end

                rad = $.elems_rotation_history[id].rotation * options.deg2radians;
                costheta = Math.cos(rad);
                sintheta = Math.sin(rad);

                var a = parseFloat(costheta).toFixed(8);
                var b = parseFloat(sintheta).toFixed(8);
                var c = parseFloat(-sintheta).toFixed(8);
                var d = parseFloat(costheta).toFixed(8);

                var sMatrix = "matrix(" + a + ", " + b + ", " + c + ", " + d + ", 0, 0)";

                if ($(this).get(0).filters) {
                    if (options.speed > 0) {
                        console.warn("You set the speed options but IE doesn't support CSS3 transitions");
                    }

                    //if the browser is IE
                    try {
                        var x = $(this).get(0).filters.item("DXImageTransform.Microsoft.Matrix").enabled;
                    }
                    catch(e) {
                        $(this).get(0).style.filter += "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand');";
                    }

                    var matrix = $(this).get(0).filters.item("DXImageTransform.Microsoft.Matrix");
                    matrix.M11 = costheta;
                    matrix.M21 = sintheta;
                    matrix.M12 = -sintheta;
                    matrix.M22 = costheta;
                    matrix.enabled = true;

                    ///debug
                    if (options.debug) {
                        console.log("Set transform = matrix[" + matrix.M11 + ", " + matrix.M21 + ", " + matrix.M12 + ", " + matrix.M22 + "]");
                    }
                    ///end
                } else {
                    //animate rotation if speed > 0s
                    if (options.speed > 0) {
                        $(this).css("-moz-transition", "all " + options.speed + "s ease-in-out");
                        $(this).css("-webkit-transition", "all " + options.speed + "s ease-in-out");
                        $(this).css("-o-transition", "all " + options.speed + "s ease-in-out");
                    }
                    $(this).css("-moz-transform", sMatrix);
                    $(this).css("-webkit-transform", sMatrix);
                    $(this).css("-o-transform", sMatrix);

                    ///debug
                    if (options.debug) {
                        console.log("Set transform = " + sMatrix);
                    }
                    ///end
                }
            });
        }
    });
})(jQuery)

Share:

PHP with MSSQL Server Simple Query

PHP with MSSQL Server Simple Query.

<?php
session_start();
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
    die('Wrong connection');
}

mssql_select_db('AssetMgmt', $link);
$User_Email="email@email.com";
$User_Pass='test';
$ssql="select *from USER_MASTER where User_Email='".$User_Email."' and User_Pass='" .$User_Pass ."'";
$result = mssql_query($ssql);
$numrow=mssql_num_rows($result);
if (!mssql_num_rows($result)) {
    echo 'Login/Pass is invalid';
}
else
{
    echo '<ul>';
    while ($row = mssql_fetch_assoc($result)) {
        echo '<li>' . $row['Name'] . ' (' . $row['EmpID'] . ')</li>';
    }
    echo '</ul>';
}
mssql_free_result($result);
?>
Share:

PHP with MSSql Server Stored procedure return records

Connect PHP with MSSql Server Stored procedure and return records.


<?php
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
    die('wrong connection');
}
mssql_select_db('amittest', $link);
$stmt = mssql_init('ListEmp');
$ID = 100;
mssql_bind($stmt, '@ID',            $ID,              SQLINT4,     false, false, 4);
$result=mssql_execute($stmt);
$num = mssql_num_rows($result);

if($num>0) {
    while($row = mssql_fetch_assoc($result)) {
        echo "<li>" . $row['ID'] . $row['EmpID']."</li>";
    }
    mssql_free_statement($stmt);
}
else {
    echo "No records found";
}
echo mssql_get_last_message();
/*
CREATE PROCEDURE dbo.ListEmpmp
    @ID bigint
    as
begin
    select ID,EmpID from Employee where ID>=@ID
End
*/
?>
Share:

PHP with MSSQL Server Stored Procedure

Here is the code to connect PHP with Mssql Server Stored procedure.



<?php
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
    die('wrong connection.');
}
mssql_select_db('amittest', $link);
$stmt = mssql_init('LoginChk');
$ID = 1;
$EmpID = 'Emp001';
$OutputLogin=0;
// Bind values
mssql_bind($stmt, '@ID',            $ID,              SQLINT4,     false, false, 60);
mssql_bind($stmt, '@EmpID',         $EmpID,           SQLVARCHAR,  false, false, 20);
mssql_bind($stmt, '@OutputLogin',     $OutputLogin,   SQLINT4,     true,  false, 20);
mssql_execute($stmt);
mssql_free_statement($stmt);
echo $OutputLogin;
echo mssql_get_last_message();
/*
////////////////////////////////////////////////////////
CREATE PROCEDURE dbo.LoginChk
    @ID varchar(50),
    @EmpID varchar(50),
    @OutputLogin bigint OUTPUT
    as
begin
    IF(EXISTS(select ID,EmpID, from Employee where ID=@ID and EmpID=@EmpID))
        begin
            --select  @OutputFirstName=vFirstName from AdminInfo where vUserId=@UserId and vPassword=@Password
            select @OutputLogin =1
        End
    else
        begin
            select @OutputLogin =0
        End
End
*/
?>
Share:

Exact date problem in ms access sql

Exact date problem in ms access sql
===============================

Suppose you have a column in the table of ms access database with DateTime. and you are storing Date and Time values. After that if you use query "select *from tbl where creationDate>=#07/30/2014# and creationDate<=#07/30/2014#  then you will surprise that no result will come as output. this is because your column is have both Data "DateTime".
So the problem is that how to show the data even data are exists in the table?
Append the time in the query as listed below:

"select *from tbl where creationDate>=#07/30/2014 00:00 AM# and creationDate<=#07/30/2014 23:59 PM#"









Share:

Generate CSV in jsp without third party utility

Generate CSV in jsp without third party utility

There are lot of third party paid and free utility that generate CSV file in JSP/Java. but the problems are to hard to implement. and may utility first create CSV file in the server, so Server space will be consumed.
To overcome all the problem I have created listed below the code. You are free to use it in you project.

<%@ page import="java.util.ArrayList"%>
<%
response.setContentType("application/csv");
response.setHeader("content-disposition","filename=test.csv");
// the session.getAttribute("listResult") is containg of comma sepearte multiple lines as listed below
//aa,10,20,30
//bb,10,20,30
//cc,10,20,30
//dd,10,20,30

ArrayList<String> list = (ArrayList<String>)session.getAttribute("listResult");
out.println("<table border='1'>");
for(int i = 0; i < list.size(); i++) {
    String myString = (String)list.get(i);

    out.println(myString);


}

out.flush();
out.close();
%>
Share:

Time in 24 Hours format in Java

How to show time in 24 Hours format.

Listed below the code; how to show time in 24 format in java

import java.io.*;
import java.util.*;
import java.util.Calendar;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Date;


public class Tm {
    public static void main(String[] args) {
        Date date = new Date();
    SimpleDateFormat simpDate;

    simpDate = new SimpleDateFormat("kk:mm:ss");
    System.out.println(simpDate.format(date));


    }
}
Share:

Watermark and heading in existing PDF Using itextSharp C#

Watermark and heading in existing PDF Using itextSharp C#

In recently my project of Learning Management System,ICT training programmes,academic software modules and teaching application software/technologies for researchers in the institutions of higher education
in Dot Net, I have faced a problem to Add Watermark and heading in existing PDF Using itextSharp C# at the same time. I have solved this problem. So If you are looking for the solution you can use my code.


  string sourceFile="c://aa.pdf", string outputFile="c://bb.pdf", string watermarkText="Heading Water Mark";
            iTextSharp.text.pdf.PdfReader reader = null;
            iTextSharp.text.pdf.PdfStamper stamper = null;
            iTextSharp.text.pdf.PdfGState gstate = null;
            iTextSharp.text.pdf.PdfContentByte contentByte = null;
            iTextSharp.text.Rectangle rect = null;
            int pageCount = 0;
            BaseFont baseFont = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.WINANSI, BaseFont.EMBEDDED);
            iTextSharp.text.Font black = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.UNDEFINED, 30f, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.GRAY);
            float fontSize = 50, xPosition = 300, yPosition = 400, angle = 55;
            try
            {
                reader = new iTextSharp.text.pdf.PdfReader(sourceFile);
                rect = reader.GetPageSizeWithRotation(1);
                stamper = new iTextSharp.text.pdf.PdfStamper(reader, new System.IO.FileStream(outputFile, System.IO.FileMode.Create));
                gstate = new iTextSharp.text.pdf.PdfGState();
                pageCount = reader.NumberOfPages;
                for (int i = 1; i <= pageCount; i++)
                {
                    contentByte = stamper.GetOverContent(i);
                    contentByte.SaveState();
                    contentByte.SetGState(gstate);
                    if (i == 1)
                    {
                        PdfPTable table = new PdfPTable(1);
                        float[] widths = new float[] { 500f };
                        table.SetWidths(widths);
                        table.TotalWidth = 600f;
                        table.LockedWidth = true;
                        Chunk chk_subject = new Chunk("My Heading Text", black);
                        Phrase ph_subject = new Phrase();
                        ph_subject.Add(chk_subject);
                        PdfPCell cell = new PdfPCell(ph_subject);
                        cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
                        cell.BorderWidthLeft = 1f;
                        cell.BorderWidthRight = 1f;
                        cell.BorderWidthTop = 1f;
                        cell.BorderWidthBottom = 1f;
                        cell.BorderColor = BaseColor.WHITE;
                        table.AddCell(cell);
                        table.WriteSelectedRows(0, -1, 0, 690, stamper.GetOverContent(1));
                    }
                    gstate.FillOpacity = (float)0.3;
                    gstate.StrokeOpacity = (float)0.3;
                    contentByte.SetGState(gstate);
                    contentByte.BeginText();
                    contentByte.SetColorFill(BaseColor.LIGHT_GRAY);
                    contentByte.SetFontAndSize(baseFont, fontSize);
                    contentByte.SetTextMatrix(30, 30);
                    contentByte.ShowTextAligned(PdfContentByte.ALIGN_CENTER, watermarkText, xPosition, yPosition, angle);
                    contentByte.EndText();
                }
                stamper.Close();
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            MessageBox.Show("Done");

Share:

Multiple attribute passing in querySelectorAll

Multiple attribute passing in querySelectorAll     Here I am demonstrating code to how to pass multiple attributes in querySelectorAll. <...

Ads Inside Post

Powered by Blogger.

Arsip