Skip to content

Instantly share code, notes, and snippets.

@huguogang
huguogang / SQL
Created March 22, 2012 17:00
SQL Server Performance DMV Sample Queries
-----------------------------------------------------------------------
-- Collection of queries that helps in performance tuning
--grant permission to user
GRANT VIEW SERVER STATE TO [user_name]
------------ based on http://msdn.microsoft.com/en-us/magazine/cc135978.aspx
---------- Uncover hidden data to optimize application performance -----------------------
-- * Number of missing indexes
@huguogang
huguogang / Delete Old Files.ps1
Created March 6, 2014 02:38
A Windows PowerShell that deleted old files
$nDays = 30
$path = "C:\temp"
$threshold = (Get-Date).AddDays(-$nDays)
Get-ChildItem -Path $path -Recurse | Where-Object {
-not $_.PSIsContainer -and $_.LastWriteTime -lt $threshold
} | Remove-Item -Force
this.map.addListener('click',
// Lambdas to the rescue, it will automatically capture this
(e: google.maps.MouseEvent) => {
// Run event handler in Angular Zone, so that change detection will work
this._ngZone.run(() =>
this.mapClick.emit(e.latLng));
});
@huguogang
huguogang / app.component.html
Created May 18, 2016 05:58
Sample client code using Google Map component
<google-map
[center]='center'
[zoom]='zoom'
(mapClick)='onMapClick($event)'
[markers]='markers'
[heatmapData]='heatmapData'>
</google-map>
@huguogang
huguogang / renderer.ts
Created May 2, 2016 02:23
Get injection of renderer in Angular 2 component
constructor(private _renderer: Renderer) { }
//handles ExtJS grid select event
//grid should have selType = 'cellmodel'
onGridSelect: function(sel, rec, row, col, opts) {
var selection = sel.nextSelection;
var dataIndex = selection.view.getGridColumns()[col].dataIndex;
var data = rec.get(dataIndex);
//...your event handler code here
}
@huguogang
huguogang / ExtJSImageWithLink.js
Created October 21, 2013 20:16
Add link to ExtJS Image component
@huguogang
huguogang / getGridSelectedData.java
Created October 11, 2013 06:03
get ExtJS grid selected data, and use JUnit assertion to verify the result
String gridQuery = "viewport #grid1";
String js = "return Ext.ComponentQuery.query('" + gridQuery
+ "')[0].getSelectionModel().getSelection()[0].data";
@SuppressWarnings(value="unchecked")
Map<String, Object> row = (Map<String, Object>)((JavascriptExecutor) _driver).executeScript(js);
assertThat("Project name", row.get("ProjectName").toString(), equalTo("Expected Project Name"));
@huguogang
huguogang / IgnoreIEZoom.java
Last active December 25, 2015 06:09
sample code to ask Selenium WebDriver to ignore IE zoom level
// ask IE to ignore zoom level, otherwise IE may have problem starting
DesiredCapabilities caps = DesiredCapabilities
.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
driver = new InternetExplorerDriver(caps);
@huguogang
huguogang / JSError.js
Created October 11, 2013 05:12
Capture Javascript error for Selenium WebDriver
//Client side utilities for Selenium tests of ExtJS web applications
//requires ExtJS and Underscore libraries
//SJTXE - Selenium JavaScript Testing eXtension for ExtJS
(function(root, Ext) {
var root = root || window;
var me = root;
var Ext = Ext;
//private vars
var hasJSError = false;