Skip to content

Instantly share code, notes, and snippets.

View gethari's full-sized avatar

Hari Haran gethari

View GitHub Profile
$creds = Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $functionAppName/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
$username = $creds.Properties.PublishingUserName
$password = $creds.Properties.PublishingPassword
$filePath = ".\MIUGDemo.zip"
$apiUrl = "https://" + $functionAppName + ".scm.azurewebsites.net/api/zipdeploy"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -InFile $filePath -ContentType "multipart/form-data"
$apiUrl = "https://api.coindesk.com/v1/bpi/currentprice.json"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$usd = $data.USD.rate
$Dashboard = New-UDDashboard -Title "Live BitCoin Tracker" -Content {
New-UDLayout -Columns 2 -Content {
New-UDRow -Columns {
New-UDMonitor -Title "USD" -Type Line -DataPointHistory 10 -Endpoint {
Invoke-WebRequest -Uri $apiUrl -Method Get | Select-Object -ExpandProperty Content | ConvertFrom-Json |
Select-Object -ExpandProperty bpi | Select-Object -ExpandProperty USD | Select-Object -ExpandProperty rate_float | Out-UDMonitorData
} -ChartBackgroundColor '#0276aa' -ChartBorderColor Black -BackgroundColor "#EDE7F6" -FontColor Black -BorderWidth 5
public class PoOrder
{
public int ponumber { get; set; }
public string name { get; set; }
public string sku { get; set; }
public double price { get; set; }
public int quantity { get; set; }
public string messagetype { get; set; }
public ShipTo shipTo { get; set; }
public BillTo billTo { get; set; }
public class AutoMapperModule: Module {
protected override void Load(ContainerBuilder builder) {
builder.RegisterAssemblyTypes(typeof(AutoMapperModule).Assembly).As < Profile > ();
builder.Register(context => new MapperConfiguration(cfg => {
foreach(var profile in context.Resolve < IEnumerable < Profile >> ()) {
cfg.AddProfile(profile);
}
})).AsSelf().SingleInstance();
public class MyClass
{
private readonly IMapper _mapper;
public MyClass(IMapper mapper){
_mapper = mapper;
}
public void DoSomething(){
_mapper.Map(appSetting, applicationSetting);
}
}
public class MyClass
{
private readonly IMapper _mapper;
private readonly ILog _logger;
public MyClass(IMapper mapper,ILog logger){
_mapper = mapper;
_logger = logger;
}
public void DoSomething(){
_mapper.Map(appSetting, applicationSetting);
public async Task<List<KeyValuePair<string, string>>> WithoutDapper(Guid id)
{
using (var connection = new SqlConnection(ConnectionString))
{
List<KeyValuePair<string, string>> propertiesList = new List<KeyValuePair<string, string>>();
SqlCommand command = new SqlCommand(queryString, connection);
command.Parameters.AddWithValue("Id", id);
connection.Open();
SqlDataReader reader = await command.ExecuteReaderAsync();
public List<StageProperty> WithDapper(Guid id)
{
List<Property> result;
using (var connection = new SqlConnection(ConnectionString))
{
result = connection.QueryAsync<Property>(queryString, new
{
Id = id
}).Result.ToList();
}
[MemoryDiagnoser]
public class Benchmark {
private readonly SearchProperties _searchProperties;
public Benchmark() {
_properties = new Properties();
} [Benchmark(Baseline = true)]
public void WithDapper() {
var ids = new List < string > {
"05edc08b-c27f-4e4d-bb5c-0045959d93a4",
"a0290013-d568-407c-a1f3-340cdff10cb5", "4f6e2712-9412-4d84-90e4-44ccab389a44", "6f9eda0e-03ba-4456-8926-65713d9a35f9", "ec186495-8191-4e20-b090-72c2005f3681", "adc6f649-3058-4cc1-94c1-e9a36d9bda3d", "8406561b-247c-4e2e-a45a-ebe35b2af715"
static void Main(string[] args)
{
BenchmarkRunner.Run<Benchmark>();
}