Thursday, October 13, 2011

how to create a TIME manipulation query in SQL SERVER 2005.

Hi Folks,
who have worked with MySQL the life is easy as there is a dedicated function for time difference. Instead in SQL Server 2005, there is no such function so life i left with various combinations of casting and substring functions. During my efforts i found a solution

SELECT *
FROM TABLEX
WHERE TABLEX.TIME BETWEEN convert(varchar(5),DATEADD(mi, -10, CURRENT_TIMESTAMP),24) AND convert(varchar(5),CURRENT_TIMESTAMP,24)



Above is for matching values for Current System time to 10 minutes before like (if systime is 08:20 now i am searching as TIME between 8:10 and 8:20 )

Same query can be used for column based value selection. like below

SELECT *
FROM TABLE_NAME
WHERE TABLE_NAME.TIME BETWEEN convert(varchar(5),DATEADD(mi, -10, TIME_COLUMN_NAME),24) AND convert(varchar(5),TIME_COLUMN_NAME,24)


The logic is using DATEADD function of SQL SERVER. "mi" is for minutes, -10 (is 10 minutes before, we can use any +/- value depending on need). Then i am putting this value in Varchar(5) i.e. 2 for mm and 2 for ss and 1 for COLON (:) then converting it with format 24 (fixed value of provided by SQL SERVER which means return only "MM:SS" part)

Wednesday, October 12, 2011

Bug in Windows 7

I am not sure though but still i can not finish to a Reason / Solution -

Create a User with a password having at least one character from @, #, ],[
Now restart the system, and try to input that password.... windows 7 don't accept it.

(NOTE - i am using Italian Keyboard, this could be issue?)

Tuesday, October 11, 2011

Auto refresh a HTML tag with jquery

NOTE - due to blogpost issue i have replaced angle brackets (< >) with closing brackets ({}) before using it please change accordingly .


include inside Head Tag as
{script language="javascript" type="text/javascript" src="js/jquery.js"} {/script}

Now inside body tag do the scripting with jquery (before using the output)
{body}
{script type="text/javascript"}
var auto_refresh = setInterval(
function ()
{
$('#MYLINK').load('OUTPUT.php?').fadeIn("fastest");
}, 180000); // refresh every 180000 milliseconds

{/script}


Now lets use the output here ....

{div class="column-small"}
{div class="portlet"}
{div class="portlet-header"}Link Videos.{/div}
{div class="portlet-content"}{div id="MYLINK"}{img src="../images/load.gif" style="height:19px; width:35px; margin:0 0 0 0;" /}
{script type="text/javascript"}$('#MYLINK').load('OUTPUT.php?').fadeIn("fastest"); {/script}
{/div}{/div}
{/div}

{/div}

{/body}


Now lets use the output here ....



just explain i am using output.php as
{?php
// just a random number for example
// i can use a image or anything using echo. .thus i can show a warning etc
echo rnd(199);
?}


with bold {img src="../images/load.gif" style="height:19px; width:35px; margin:0 0 0 0;" /} i am loading an image in background....so the end user see something is working... (just to manage delay with loading image).

Word Password Cracking - No need to pay any money

It happens... yes "Shit happens ;)".

So you forgot the word password; here is the shortest and easiest solution BUT be ready for some re-formatting if needed.

MS-OFFICE 2007.
Open a new blank document.
click the Menu Insert->Object ->Text from File
Select the file (which has the password and you have lost it ;))
Save the new file as new name.

Now you close it. and re-open the file you have saved in above step. It's all without password :D.

Script for RAW HTTP REQUEST (posting raw data in XML)

$raw = new HttpRequest(“http://host-name/services/airplayer/”, HttpRequest::METH_POST);

store your xml in the variable $xml

$raw->setContentType(“text/xml charset=utf-8″);
$a = $raw->setRawPostData($xml);
$raw->addRawPostData($xml);
$message = new HttpMessage();
$message = $raw->send();
echo $message->tostring();

To use HttpRequest class u need to uncomment the php_http.dll present in u r php.ini file and then restart u r apache.

while creating object, you need to specify the php file location url where u receive the RAW HTTP REQUEST

here u can sepcify php script located on diferent server also.

second parameter denotes method i.e GET OR POST u can send raw data either in POST format OR in GET format.

Friday, October 22, 2010

Open Source IDE

best one ...

http://quanta.kdewebdev.org

Friday, October 1, 2010

To create a perfect italian week-day-month

this helps to find last day with weekday Name, day, month correctly in italian format, can work independently on any Locale setting.

{php}
setlocale(LC_TIME, 'ita');
$mesi = array(1=>'Gennaio', 'Febbraio', 'Marzo', 'Aprile',
'Maggio', 'Giugno', 'Luglio', 'Agosto',
'Settembre', 'Ottobre', 'Novembre','Dicembre');
// For UTF -coding replaced Igrave with ASCII codes to display as normal.
$giorni = array('Domenica','Lunedì','Martedì','Mercoledì',
'Giovedì','Venerdì','Sabato');

list($sett,$giorno,$mese,$anno) = explode('-',date('w-d-n-Y', strtotime("-1 day")));
echo $giorni[$sett],' ',$giorno,' ',$mesi[$mese],' ',$anno;
{/php}

Put your specific add / minus in strtotime.