This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Extension()> _ | |
Public Function ToCsvValue(ByVal source As Object, Optional ByVal addDelimiter As Boolean = True) As String | |
Dim csvValue As String | |
If source Is Nothing Then | |
csvValue = "" | |
Else | |
csvValue = CStr(source).Trim | |
End If | |
If addDelimiter Then | |
Return If(csvValue.IndexOf(",") > -1, String.Format("""{0}"",", csvValue), String.Format("{0},", csvValue)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<polymer-element name="my-element"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub WaitForFileToBeAccessible(ByVal fileWaitingOn As String) | |
Try | |
Using fs As FileStream = New FileStream(fileWaitingOn, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 100) | |
fs.ReadByte() | |
End Using | |
Catch ex As Exception | |
System.Threading.Thread.Sleep(10000) | |
WaitForFileToBeAccessible(fileWaitingOn) | |
End Try | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System.Net.Sockets | |
Public Function SmtpAlive(ByVal hostName As String, ByVal port As Integer) | |
Using tcp As New TcpClient | |
Try | |
tcp.Connect(hostName, port) | |
Return True | |
Catch ex As Exception | |
' server not found | |
Return False | |
End Try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Credit goes to this blog post https://dotnettips.wordpress.com/2017/02/20/net-framework-core-getting-the-app-data-folder/ | |
//For .Net Core | |
public static string AppDataFolder() | |
{ | |
var userPath = Environment.GetEnvironmentVariable( | |
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? | |
"LOCALAPPDATA" : "Home"); | |
var assy = System.Reflection.Assembly.GetEntryAssembly(); | |
var companyName = assy.GetCustomAttributes<AssemblyCompanyAttribute>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Credit goes to this blog post https://dotnettips.wordpress.com/2013/03/07/retrieving-application-settings/ | |
//USAGE: int serverPort = GetAppSetting<int>("server_port"); | |
public static T GetAppSetting<T>(string key) | |
{ | |
if (ConfigurationManager.AppSettings.AllKeys.Contains(key)) | |
{ | |
return (T)System.Convert.ChangeType(ConfigurationManager.AppSettings[key], | |
typeof(T), CultureInfo.InvariantCulture); | |
} | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Credit goes to this post https://stackoverflow.com/questions/10541770/convert-string-array-to-integer-array Answer from janseeuw. | |
var arrayOfNumbers = arrayOfStrings.map(Number); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setget(selector) { | |
return { | |
get: function () { | |
return $(selector).val(); | |
}, | |
set: function (newValue) { | |
$(selector).val(newValue); | |
} | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Referenced from https://www.sitepoint.com/get-url-parameters-with-javascript/ | |
function getAllUrlParams(url) { | |
// get query string from url (optional) or window | |
var queryString = url ? url.split('?')[1] : window.location.search.slice(1); | |
// we'll store the parameters here | |
var obj = {}; |
OlderNewer