Skip to content

Instantly share code, notes, and snippets.

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) { }
@huguogang
huguogang / CFScript Problem
Created February 23, 2015 20:16
CFScript Problem
<cfscript>
private struct function test() {
if(1 == 1) {
if(1 == 0) {
writeOutput("1==0");
};
writeOutput("true");
return {data = 1};
}
writeOutput("false");
@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
@huguogang
huguogang / ReadMSAccess.cfm
Last active August 29, 2015 13:56
Sample code to read MS Access file into CFQuery
<cfscript>
//list all the JDBC drivers for diagnosis purpose
factory = createObject("java","coldfusion.server.ServiceFactory");
writeDump(factory.dataSourceService.getDrivers());
fileName = "d:/temp/temp.mdb";
classLoader = createObject("java","java.lang.Class");
driver = classLoader.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//connect to MDB using 64-bit java and 64-bit MS Access Driver
connStr = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" & fileName;
//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);