Skip to content

Instantly share code, notes, and snippets.

@MasayukiOzawa
MasayukiOzawa / GPU 版 Tensorflow のテスト用クエリ.sql
Last active September 20, 2017 04:02
ML Services のサンプル
exec sp_execute_external_script @language =N'Python',
@script=N'
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
import tensorflow as tf
sess = tf.InteractiveSession()
x = tf.placeholder(tf.float32, shape=[None, 784])
@MasayukiOzawa
MasayukiOzawa / Ubuntu の AAD 認証の有効化.txt
Created July 20, 2017 01:51
Ubuntu の AAD 認証の有効化
# ドメイン名の大文字 / 小文字の入力が意識されるため、以下のスクリプトの大文字/小文字はそのままの形式で適宜ドメイン名を変更
sudo apt-get install -y realmd krb5-user packagekit
# インストール時に入力が求められるドメイン名については、大文字で指定
# https://answers.launchpad.net/ubuntu/+question/293540
sudo realm discover contoso.com -v
sudo realm join contoso.com -U 'LinuxADUser@CONTOSO.COM' -v
# Domain Users 権限で JOIN させる場合、事前にコンピューターアカウントを作成し無効な状態としておき、コマンドで使用するユーザーのフルコントロールを付与しておく
@MasayukiOzawa
MasayukiOzawa / Install-JapaneseLanguagePack.ps1
Last active June 8, 2017 08:04
英語 OS に日本語の言語パックをインストール
function Install-JapaneseLanguagePack
{
Param(
[parameter(mandatory=$true)]
$AdminUser = "",
[parameter(mandatory=$true)]
$AdminPassword = "",
[parameter(mandatory=$true)]
[ValidateSet("2012" , "2012R2", "2016")]
$OSVersion = ""
DROP TABLE IF EXISTS T_EmpGO
CREATE TABLE T_Emp( ID int NOT NULL, Name Varchar(20), Status Varchar(1), Flag tinyint NOT NULL, UpdDate Datetime, CONSTRAINT PK_ID PRIMARY KEY CLUSTERED(ID)) GO
CREATE INDEX IX_Name on T_Emp(Name) CREATE INDEX IX_Status on T_Emp(Status) CREATE INDEX IX_Flag on T_Emp(Flag) CREATE INDEX IX_UpdDate on T_Emp(UpdDate) GO
TRUNCATE TABLE T_Emp GO DECLARE @i int = 1 DECLARE @name varchar(10)
WHILE @i <= 10  BEGIN SET @name = 'Name' + RIGHT('000000'+ CONVERT(VARCHAR,@i),6)  INSERT INTO T_Emp VALUES( @i,@name,1,0,Getdate() )  SET @i += 1 END GO
UPDATE STATISTICS T_Emp IX_FlagGO
DBCC SHOW_STATISTICS ('T_Emp', 'IX_Flag') WITH STATS_STREAM  GO
SET NOCOUNT ONGODECLARE @i int = 11DECLARE @name varchar(10) BEGIN TRANWHILE @i <= 1000000 BEGIN  SET @i += 1  SET @name = 'Name' + RIGHT('000000'+ CONVERT(VARCHAR,@i),6)  INSERT INTO T_Emp VALUES( @i,@name,2,1,Getdate() )  SET @i += 1END COMMIT TRANGO
UPDATE STATISTICS T_Emp IX_Flag WITH FULLSCANGO
DBCC SHOW_STATISTICS ('T_Emp', 'IX_Flag') WITH STATS
create table #SVer(ID int, Name sysname, Internal_Value int, Value nvarchar(512))
insert #SVer exec master.dbo.xp_msver
declare @SmoRoot nvarchar(512)
exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\Setup', N'SQLPath', @SmoRoot OUTPUT
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters" : {
"userImageStorageAccountName": {
"type": "string"
},
"userImageStorageContainerName" : {
"type" : "string",
"defaultValue" : "images"
$sqlinstancename = "MSSQL13.MSSQLSERVER"
$SQLBinPath = (Get-ItemProperty ([io.path]::combine("HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server", $sqlinstancename, "Setup"))).SQLBinRoot
$param = @{
ExclusionExtension = "mdf", "ldf", "ndf" , "bak", "trn"
ExclusionProcess = (Get-Item (Join-Path $SQLBinPath "sqlservr.exe"))
ExclusionPath = "C:\Windows\Cluster"
}
Set-MpPreference @param
# https://azure.microsoft.com/ja-jp/documentation/articles/sql-database-develop-direct-route-ports-adonet-v12/
# https://blogs.msdn.microsoft.com/sqlcat/2016/09/08/connect-to-azure-sql-database-v12-via-redirection/
# https://msdn.microsoft.com/en-us/library/azure/mt604439.aspx
$adTenant = "hogehoge.onmicrosoft.com"
$subscriptionid = "xxxxxxxxxxx"
$resourgegroup = "groupname"
$servername = "servername"
$user = "hogehoge@hogehoge.onmicrosoft.com"
$password = "M@sterEr0s"
-- https://azure.microsoft.com/ja-jp/documentation/articles/sql-data-warehouse-develop-concurrency/
-- ワークロードグループのリソースと使用状況の確認
WITH rg
AS
( SELECT pn.name AS node_name
, pn.[type] AS node_type
, pn.pdw_node_id AS node_id
, rp.name AS pool_name
-- クエリ情報の実行時間上位 50 件の取得 (ポータルで実行されているクエリ)
select top 50
(case when requests.status = 'Completed' then 100
when progress.total_steps = 0 then 0
else 100 * progress.completed_steps / progress.total_steps end) as progress_percent,
requests.status,
requests.request_id,
sessions.login_name,
requests.start_time,
requests.end_time,