Skip to content

Instantly share code, notes, and snippets.

View marifrahman's full-sized avatar

Mohammad Arifur Rahaman marifrahman

View GitHub Profile
@marifrahman
marifrahman / sapitest.vbs
Created March 12, 2012 18:05
Simple SAPI test
Dim message, sapi
message=InputBox("What do you want me to say?","Speak to Me")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak message
@marifrahman
marifrahman / php soap client for JAX-WS
Created March 24, 2012 13:44
PHP SOAP Client to consume JAX-WS with Basic Http Authentication
<?php
class JaxWsSoapClient extends SoapClient
{
public function __call($method, $arguments){
$response = parent::__call($method, $arguments);
return $response->return;
}
}
@marifrahman
marifrahman / svn post-commit script
Created April 8, 2012 09:41
Using SVN post-commit hook to update only files that have been commited
#!/bin/sh
REPOS="$1"
REV="$2"
# A - Item added to repository
# D - Item deleted from repository
# U - File contents changed
# _U - Properties of item changed; note the leading underscore
# UU - File contents and properties changed
@marifrahman
marifrahman / gist:2633873
Created May 8, 2012 09:28
getDateRangeArray
function getDateRangeArray($strDateFrom, $strDateTo) {
// takes two dates formatted as YYYY-MM-DD and creates an
// inclusive array of the dates between the from and to dates.
// could test validity of dates here but I'm already doing
// that in the main script
$aryRange = array();
$iDateFrom = mktime(1, 0, 0, substr($strDateFrom, 5, 2), substr($strDateFrom, 8, 2), substr($strDateFrom, 0, 4));
$iDateTo = mktime(1, 0, 0, substr($strDateTo, 5, 2), substr($strDateTo, 8, 2), substr($strDateTo, 0, 4));
@marifrahman
marifrahman / SQL_Update_sequentially
Created June 4, 2013 00:53
SQL Query for MS SQL Server to sequentially update a column
DECLARE @myVar numeric
SET @myVar = 10
UPDATE
tblMyTable
SET
@myvar = myId = @myVar + 1
Where condition = 'Something' And isDeleted = 0
@marifrahman
marifrahman / SQL_DB_Queries_Being_Processed
Last active December 18, 2015 04:39
Microsoft SQL Server Query to get the query being executed on a Database.
select S.program_name,DB_Name(S.dbid),min(S.last_batch), t.text as 'last_sql',S.loginame,count(*)
from sys.sysprocesses S
CROSS APPLY sys.dm_exec_sql_text (S.sql_handle) t
where S.dbid > 3
and DB_NAME (S.dbid) = 'MyDatabase'
group by S.program_name,S.dbid,t.text,S.loginame having count(*) > 6
order by count(*) desc
@marifrahman
marifrahman / css_textbox_styling
Created June 18, 2013 02:32
TextBox Styling with CSS and background image
.txtBox
{
background: url(images/txtbox.png) no-repeat center;
border-style: none;
width: 207px;
height: 30px;
line-height: 30px;
font-family: Calibri, Verdana, Arial, Helvetica, Sans-Serif;
font-size: 11pt;
font-weight: bold;
@marifrahman
marifrahman / Sqlserver_SQL_Insert_or_update
Created June 28, 2013 07:16
Sql server specific SQL to update a record if exists or insert as new
IF EXISTS (SELECT NULL FROM myTable WHERE myId = 'something')
UPDATE myTable SET some_other_column = 'some_other_thing'
ELSE
INSERT INTO myTable Values('something', 'some_other_thing',some_flag_may_be)
@marifrahman
marifrahman / SQL_Server_Pagination
Last active December 19, 2015 11:09
Pagination on the result set returned by a query
//Before SQL Server 2012
SELECT * FROM LargeTable WHERE indexColumn >= 'something' ORDER BY indexColumn
SELECT *
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY [PK] ) AS RowNum, *
FROM [funtest].[dbo].[LargeTable]
-- WHERE indexColumn >= 'something'
) AS RowConstrainedResult
WHERE RowNum >= 50
AND RowNum <= 700
@marifrahman
marifrahman / SQL_server_get_duplicate
Created July 18, 2013 03:08
Get duplicate record in a column for each group
use *DATABASE_NAME*
go
SELECT *YOUR_FIELD*, COUNT(*) AS dupes
FROM *YOUR_TABLE_NAME*
GROUP BY *YOUR_FIELD*
HAVING (COUNT(*) > 1)