Sep 18 2019

MSSQL – get current running SQL queries

SELECT sqltext.TEXT,
req.session_id,
req.status,
req.command,
req.cpu_time,
req.total_elapsed_time
FROM sys.dm_exec_requests req
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext

Sep 11 2019

jQuery – get checked radio button by class

element = $("input:radio.someClass:checked");
value = $("input:radio.someClass:checked").val();

Sep 9 2019

Classic ASP – Strip HTML Function


<%
FUNCTION stripHTML(strHTML)
  Dim objRegExp, strOutput, tempStr
  Set objRegExp = New Regexp
  objRegExp.IgnoreCase = True
  objRegExp.Global = True
  objRegExp.Pattern = "<(.|n)+?>"
  'Replace all HTML tag matches with the empty string
  strOutput = objRegExp.Replace(strHTML, "")
  'Replace all < and > with &lt; and &gt;
  strOutput = Replace(strOutput, "<", "&lt;")
  strOutput = Replace(strOutput, ">", "&gt;")
  stripHTML = strOutput    'Return the value of strOutput
  Set objRegExp = Nothing
END FUNCTION
%>

source: https://gist.github.com/gwobcke/1027133


Sep 9 2019

Classic ASP – Strip Special Character Function


<%
Function StripSpecialChar(strInput)
	Dim objRegExp
	Set objRegExp = New Regexp
	objRegExp.IgnoreCase = True
	objRegExp.Global = True
	objRegExp.Pattern = "[\+\#\@\&\%\$\?\*]"
	'//Replace all character matches with an Empty String
	StripSpecialChar = objRegExp.Replace(strInput, "")
	Set objRegExp = Nothing
End Function
%>

source: https://gist.github.com/gwobcke/1027138/revisions


Sep 8 2019

Classic ASP – IN ARRAY

Function InArray(Needle, Haystack)
    Dim i, x
    InArray = False

    For i = 0 To Ubound(Haystack)
        If IsArray(Needle) = True Then
            For x = 0 To Ubound(Needle)
                If Trim(Haystack(i)) = Trim(Needle(x)) Then
                    InArray = True
                    Exit Function
                End If
            Next
        Else
            If Trim(Haystack(i)) = Trim(Needle) Then
                InArray = True
                Exit Function
            End If
        End If
    Next
End Function

SOURCE: https://gist.github.com/gwobcke/1044367


Sep 8 2019

ASP – ArrayList

Option Explicit

dim list
Set list = CreateObject("System.Collections.ArrayList")
list.Add "Banana"
list.Add "Apple"
list.Add "Pear"

'list.Sort
'list.Reverse

response.write list.Count                 ' --> 3
response.write list.Item(0)               ' --> Pear
response.write list.IndexOf("Apple", 0)   ' --> 2
response.write join(list.ToArray(), ", ") ' --> Pear, Banana, Apple

source: https://stackoverflow.com/questions/13585660/lists-in-vbscript


Aug 29 2019

jQuery: find element by text

<div>This is a test</div>
<div><span>Another Div</span></div>

$('div:contains("Another")').css('background-color', 'red');

Aug 28 2019

MSSQL – Set IDENTITY_INSERT OFF for all tables

select 'set identity_insert ['+s.name+'].['+o.name+'] off'
from sys.objects o
inner join sys.schemas s on s.schema_id=o.schema_id
where o.[type]='U'
and exists(select 1 from sys.columns where object_id=o.object_id and is_identity=1)

Then copy & paste the resulting SQL into another query window and run

source: https://stackoverflow.com/questions/10116759/set-identity-insert-off-for-all-tables


Aug 21 2019

ColdFusion – Creating Copy of a Structure Using CFSet, Duplicate and Structcopy

Using CFSet

Creating a copy of a Structure using CFSet will result in a new variable having a reference to the original Structure;
changes will affect the original Structure.

******************************************************

Using Duplicate

Creating a copy of a Structure using Duplicate will result in a new variable containing no reference to the original Structure but rather a snapshot of its current contents.
changes will NOT affect the original Structure.

******************************************************

Using Strcutcopy

Strcutcopy is where most people get confused.
We can say Structcopy is between CFSet and Duplicate.
When we use Structcopy, a new structure will be created; however, references to nested structures, objects, and query variables will be maintained from the original Structure.
changes will affect the original Structure.

******************************************************

Source: https://www.experts-exchange.com/articles/8971/Differences-in-Creating-Copy-of-a-Structure-Using-CFSet-Duplicate-and-Structcopy-in-ColdFusion.html


Mar 16 2019

MSSQL – get total records in all tables

SELECT
    t.NAME AS TableName,
    i.name as indexName,
    p.[Rows],
    sum(a.total_pages) as TotalPages,
    sum(a.used_pages) as UsedPages,
    sum(a.data_pages) as DataPages,
    (sum(a.total_pages) * 8 ) / 1024 as TotalSpaceMB,
    (sum(a.used_pages) * 8 ) / 1024 as UsedSpaceMB,
    (sum(a.data_pages) * 8 ) / 1024 as DataSpaceMB
FROM
    sys.tables t
INNER JOIN
    sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
    sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
    sys.allocation_units a ON p.partition_id = a.container_id
WHERE
    t.NAME NOT LIKE 'dt%' AND
    i.OBJECT_ID > 255 AND
    i.index_id <= 1
GROUP BY
    t.NAME, i.object_id, i.index_id, i.name, p.[Rows]
ORDER BY
    object_name(i.object_id)

https://stackoverflow.com/questions/1443704/query-to-list-number-of-records-in-each-table-in-a-database