Skip to content

Instantly share code, notes, and snippets.

@dimaxweb
dimaxweb / main.ts
Last active December 18, 2019 07:09
Enable debugTools Angular8
import {ApplicationRef} from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import {enableDebugTools} from '@angular/platform-browser';
platformBrowserDynamic().bootstrapModule(AppModule).then(moduleRef => {
const applicationRef = moduleRef.injector.get(ApplicationRef);
const componentRef = applicationRef.components[0];
// allows to run `ng.profiler.timeChangeDetection();`
enableDebugTools(componentRef);
@dimaxweb
dimaxweb / XmlIslandsParse
Created May 4, 2013 10:03
Xml parsing without ActiveX in Internet Explorer.Works only in IE!!!
funtion parseWitoutActiveX(str)
var doc= null;
var xmlIsland = document.createElement('xml');
if(xmlIsland){
xmlIsland.setAttribute('id','xmlActiveXGetRid');
xmlIsland.innerHTML = str;
document.body.appendChild(xmlIsland);
var doc = xmlIsland.XMLDocument;
document.body.removeChild(xmlIsland);
return doc;
@dimaxweb
dimaxweb / NumberOdConnections
Created October 8, 2012 09:17
Check number of connections opened against the database - SQL Server 2005
SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame
@dimaxweb
dimaxweb / Unique Identifier
Created September 29, 2012 06:49
Get unique identifier
function getUniqueId () {
return Math.round(Math.random() * 9999999999);
}
@dimaxweb
dimaxweb / JsEscape
Created September 28, 2012 18:49
Make string securely embeddable in to JavaScript function call
//escape the text in order to make it secure for embedding in JavaScript.
function jsEscape(content) {
return content.replace(/(['\\])/g, '\\$1')
.replace(/[\f]/g, "\\f")
.replace(/[\b]/g, "\\b")
.replace(/[\n]/g, "\\n")
.replace(/[\t]/g, "\\t")
.replace(/[\r]/g, "\\r")
.replace(/[\u2028]/g, "\\u2028")
.replace(/[\u2029]/g, "\\u2029");