0

ORACLE - UPDATE SEQUENCE VALUE USING LOOP

 DECLARE  l_counter NUMBER := 0;

t NUMBER:=0;

BEGIN

LOOP

    l_counter := l_counter + 1;

    IF l_counter > 32690 THEN

      EXIT;

    END IF;

    SELECT ISEQ$$_832661.nextval INTO t from dual;

  END LOOP;

END;

0

IIS - Cache Control must-revalidate"

Reference : Deploying to Microsoft Internet Information Server (IIS) | Gatsby (gatsbyjs.com)


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <location path="static">
        <system.webServer>
            <httpProtocol>
                <customHeaders>
                    <remove name="cache-control" />
                    <add name="cache-control" value="public, max-age=31536000, immutable" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
    <location path="page-data">
        <system.webServer>
            <httpProtocol>
                <customHeaders>
                    <remove name="cache-control" />
                    <add name="cache-control" value="public, max-age=0, must-revalidate" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </location>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
        </staticContent>
        <rewrite>
            <outboundRules>
              <rule name="AdjustCacheForDontCacheFiles" preCondition="IsDontCacheFile" stopProcessing="true">
                <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
                <action type="Rewrite" value="public, max-age=0, must-revalidate" />
              </rule>
              <rule name="AdjustCacheForCachePermanentlyFiles" preCondition="IsCachePermanentlyFile" stopProcessing="true">
                <match serverVariable="RESPONSE_Cache-Control" pattern=".*" />
                <action type="Rewrite" value="public, max-age=31536000, immutable" />
              </rule>
              <preConditions>
                <preCondition name="IsDontCacheFile">
                  <add input="{REQUEST_FILENAME}" pattern="(.*\.html)|(sw\.js)|(app\-data\.json)|(page\-data\.json)" />
                </preCondition>
                <preCondition name="IsCachePermanentlyFile">
                  <add input="{REQUEST_FILENAME}" pattern="((.*\.js)|(.*\.css))$" />
                </preCondition>
              </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>
0

SQL Server - Kill all Connected connection

Reference : https://stackoverflow.com/questions/7197574/script-to-kill-all-connections-to-a-database-more-than-restricted-user-rollback 

 For MS SQL Server 2012 and above


USE master;

DECLARE @kill varchar(8000); SET @kill = '';  
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), spid) + ';'  
FROM master..sysprocesses  
WHERE dbid = db_id('MyDB')

EXEC(@kill);



 For MS SQL Server 2000, 2005, 2008

 USE [master];
DECLARE @kill varchar(8000) = '';  
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'  
FROM sys.dm_exec_sessions
WHERE database_id  = db_id('MyDB')

EXEC(@kill);
0

SQL Server - find users connected to databases

Reference: https://jimsalasek.com/2019/01/09/sql-server-find-users-connected-to-databases/

SELECT @@ServerName AS server
 ,NAME AS DatabaseName
 ,COUNT(STATUS) AS number_of_connections
 ,GETDATE() AS Query_Run_Time
FROM sys.databases sd
LEFT JOIN sysprocesses sp ON sd.database_id = sp.dbid
WHERE NAME not in ('master','model','msdb','tempdb')
GROUP BY NAME

With actual usernames and machines that are connected


SELECT @@ServerName AS SERVER
 ,NAME
 ,login_time
 ,STATUS
 ,hostname
 ,program_name
 ,nt_username
 ,loginame
FROM sys.databases d
LEFT JOIN sysprocesses sp ON d.database_id = sp.dbid
WHERE  NAME not in ('master','model','msdb','tempdb')
 AND loginame IS NOT NULL order by 2



0

Automatically Replacing an Image on an HTML Page When it is Not Found

Reference : Automatically Replacing an Image on an HTML Page When it is Not Found - CodeProject


 <div>
    <img src="error.jpg" onerror="replaceImage(this, 'replacement.jpg');"
     title="This image is replaced on an error"/>
  </div>
 
  <script type="text/javascript">
    function replaceImage(image, replacementUrl){
      image.removeAttribute("onerror");
      image.src=replacementUrl;
    }
  </script>
0

Laravel get active session in minutes

select from_unixtime(`last_activity`) as lastdt from `sessions` WHERE from_unixtime(`last_activity`) >= NOW() - INTERVAL 15 MINUTE

ORDER BY last_activity DESC;


0

Datatable Search On Enter

Finally !!!!

Reference: jquery - datatables global search on keypress of enter key instead of any key keypress - Stack Overflow

Need to declare function on initComplete event. And use search function.

Datatable version 1.11.

$(function() {
    var  table = $('#DataTable1').DataTable({
            proccessing: true,
            searching: true,
            paging: true,
            serverSide: true,
            initComplete: function() {
                $('.dataTables_filter input').unbind();
                $('.dataTables_filter input').bind('keyup', function(e){
                    var code = e.keyCode || e.which;
                    if (code == 13) {
                        table.search(this.value).draw();
                    }
                });
            },
            ajax: {
            url: '@Url.Action("Paginacao")',
            type: 'POST'
        },
        language: {
            url: '/plugins/datatables/lang/Portuguese-Brasil.json'
        },
        columns:
        [
                { "data": "id", visible: false },
                { "data": "nome", "autoWidth": true },
                { "data": "cnpj", "autoWidth": true },
            {
                "render": function(data, type, full, meta) {
                    return '<a href=@Url.Action("Editar", "Usuario")?id='+full.id+'><b><i class=\"fa fa-edit bigfonts\"></i> Editar</b></a>';
                }
            }
        ]
    });

});
 
Copyright © peyotest