Skip to content

Instantly share code, notes, and snippets.

View msdotnetclr's full-sized avatar

Jian (Miracle) Zhou msdotnetclr

View GitHub Profile
[mergetool]
prompt = false
keepBackup = false
keepTemporaries = false
[merge]
tool = winmerge
[mergetool "winmerge"]
name = WinMerge
@msdotnetclr
msdotnetclr / Example.html
Created October 10, 2016 14:25 — forked from Danielku15/Example.html
A MediaTypeFormatter for WebApi for multipart/form-data including file uploads
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>File Upload example</title>
<link href="/Content/bootstrap.css" rel="stylesheet" />
</head>
<body>
<form action="api/Upload" method="post">
<div class="form-group">
@msdotnetclr
msdotnetclr / run_azure_sql_sp_with_powershell.md
Last active February 21, 2020 07:49
Run Stored Procedure in Azure SQL with PowerShell Script
  1. Install PowerShell. Follow instructions at https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell?view=powershell-5.1
  2. Install Azure PowerShell 4.4. Follow instructions at https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-4.4.0
  3. Start PowerShell and execute the following commands to create a credential file for Azure auto-login later.
######################################################################
# interactive login to Azure Resource Manager with your Azure Account
Login-AzureRmAccount 
# print the list of subscriptions you have access to
Get-AzureRmSubscription
@msdotnetclr
msdotnetclr / Starburst-downloads.md
Last active January 4, 2019 14:29
Teradata Presto Downloads

Download Page URL:

https://www.starburstdata.com/download-links

Presto Server

RPM

@msdotnetclr
msdotnetclr / start_vm.ps1
Last active January 24, 2018 14:35
Use PowerShell to start an Azure VM
# --- begin prerequisite ---
# interactive login to Azure Resource Manager with your Azure Account
Login-AzureRmAccount
# print the list of subscriptions you have access to
Get-AzureRmSubscription
# save your credential to a JSON file for auto-login later on
Save-AzureRmContext -Path "C:\private\azure-credential.json"
# --- end prerequisite ---
# --- begin script ---
@msdotnetclr
msdotnetclr / redis-conditional-set.txt
Last active April 1, 2024 13:26
Redis LUA: set or update key if new value is higher/lower than current
# Basic benchmarks
# SET key val # 87489.06
# SETRANGE key2 6 "Redis" # 75757.58 req/s
# INCR key 245 # 70224.72 req/s
# INCRBY key 245 22 # 67114.09 req/s
# EVAL SET key val # 46296.29 req/s
# SETIFHIGHER (set or update key if new value is higher than current) # 41666.67 req/s
# if not exists return OK , if updated return the increment , if not updated return 0
SCRIPT LOAD "local c = tonumber(redis.call('get', KEYS[1])); if c then if tonumber(ARGV[1]) > c then redis.call('set', KEYS[1], ARGV[1]) return tonumber(ARGV[1]) - c else return 0 end else return redis.call('set', KEYS[1], ARGV[1]) end"
@msdotnetclr
msdotnetclr / import-gzip-csv-from-web-to-power-bi.md
Last active November 14, 2022 17:02
Import GZipped CSV file from the web to Power BI
  1. Get Data -> Web, choose "Basic", enter URL. E.g. https://myteststorage.blob.core.windows.net/pmdogy/20180129/csv/shrmyd/shrmyd.csv.gz?st=2018-02-05T08%3A57%3A00Z&se=2018-02-05T16%3A57%3A00Z&sp=r&sv=2017-04-17&sr=b&sig=PbFVzUv%2FBwrOCR0RcuzgVw%2F9nVFFmbo%2BXOJusO1yo9E%3D Power BI Query Editor will display a single icon for the web blob with the source domain name and content size.
  2. Go to View -> Advanced Editor. The script will be like this:
let
    Source = Web.Contents("https://myteststorage.blob.core.windows.net/pmdogy/20180129/csv/shrmyd/shrmyd.csv.gz?st=2018-02-05T08%3A57%3A00Z&se=2018-02-05T16%3A57%3A00Z&sp=r&sv=2017-04-17&sr=b&sig=PbFVzUv%2FBwrOCR0RcuzgVw%2F9nVFFmbo%2BXOJusO1yo9E%3D")
in
    Source
@msdotnetclr
msdotnetclr / NvvCSVClasses.cs
Created February 5, 2018 16:54
NVV CSV Classes
/*****************************************************/
/*** Copyright (c) 2014 Vladimir Nikitenko ***/
/*** Code Project Open License (CPOL) ***/
/*** (http://www.codeproject.com/info/cpol10.aspx) ***/
/*****************************************************/
/***** NvvCSVClasses.cs *****
===== History: