正規表現でasciiコード文字クラス

2018-12-05 22:14:34 | 正規表現
色々やり方あると思いますが、x0020-x007eまでに制限したい場合は、
これが一番わかりやすいと思う。
[0-9a-zA-Z -/:-@[~]
hex指定でもいいと思うが、コード見れば何したいか想像つく。

ちなみに-指定で0-9,a-zはOKだが、:-@は気持ち悪いなんて指摘が会社で
あったけど、指摘者の話によると、0-9,a-zは大抵想定通りの順番で並びを保持しているからOK
なんだとか、上手くいくのはたまたまだとか笑

[0-9]のハイフンは
オライリーの正規表現クックブックによると、

「ハイフン(-)は2個の文字の間に配置されると範囲を形成します。文字クラス内の文字範囲はハイフン
の直前の文字と直後の文字の文字コードがその間の数字になっている全ての文字を含みます」

ってことだから、a-zと:-@の指定は文字コードの順番を利用している指定方法という点では全く
同じ意味。指摘者の知識があいまいな故の指摘としか思えない。

powershell4

2018-07-01 22:25:42 | powershell
#定数宣言
Set-Variable -name XAML_FILE -value "combo.xaml" -Option Constant -Scope script
Set-Variable -name CSVOUTPUT_FILE -value "output.csv" -Option Constant -Scope script
Set-Variable -name CONFIGJSON_FILE -value "config.json" -Option Constant -Scope script

$Datas = @()


$path = $MyInvocation.MyCommand.Path | Split-Path -Parent
$xaml = [System.IO.File]::ReadAllText($path + "\" + $XAML_FILE, [System.Text.Encoding]::UTF8)
$form = [System.Windows.Markup.XamlReader]::Parse($xaml)

$configJson = $path + "\" + $CONFIGJSON_FILE
$obj = Get-Content $configJson -Encoding UTF8 -Raw | ConvertFrom-Json

$outputFilePath = $path +"\" + $CSVOUTPUT_FILE

$comboBox = $form.FindName("Combo1")
# fill the combobox with some powershell objects
$comboBox.ItemsSource = $obj.契約顧客リスト
# tell the combobox to use the property "DisplayName" to display the object in its list
$comboBox.DisplayMemberPath = 'Name'
$comboBox.SelectedValuePath = "Id"
# tell the combobox to preselect the first element
$comboBox.SelectedIndex = 0

$listView = $form.FindName("listView")
$listView.ItemsSource = @($comboBox.SelectedItem.請求内訳)

$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = "CSVファイル(*.csv)|*.csv"
$dialog.Title = "ファイルを選択してください。"
$fileSelectBtn = $form.FindName("fileSelectBtn")
$selectFilePath = $form.FindName("selectFilePath")
$fileSelect = $form.FindName("selectFilePath")
$fileUploadBtn = $form.FindName("uploadBtn")

$userid = $form.FindName("userId")
$password = $form.FindName("password")
$proxyUserid = $form.FindName("proxyUserId")
$proxyPassword = $form.FindName("proxyPassword")
$useridPasswordBtn = $form.FindName("useridPasswordBtn")

$comboBoxCfg = $form.FindName("ComboConfig")
# fill the combobox with some powershell objects
$comboBoxCfg.ItemsSource = $obj.契約顧客リスト
# tell the combobox to use the property "DisplayName" to display the object in its list
$comboBoxCfg.DisplayMemberPath = 'Name'
$comboBoxCfg.SelectedValuePath = "Id"
# tell the combobox to preselect the first element
$comboBoxCfg.SelectedIndex = 0

$datagrid = $form.FindName("datagrid")
$datagrid.ItemsSource = @($comboBoxCfg.SelectedItem.請求内訳)

$configUpdateBtn = $form.FindName("configUpdateBtn")


function uploadFunc($inputFilePath) {

$parms = "/c " + $path + "\test.bat"
$inputObject = Start-Process -FilePath cmd.exe -ArgumentList $parms -PassThru
Wait-Process -InputObject $inputObject

$parms = "/c " + $path + "\test2.bat"
$inputObject = Start-Process -FilePath cmd.exe -ArgumentList $parms -PassThru
Wait-Process -InputObject $inputObject



}

function processExecute( $executePgm, $argument, $workingDir) {

$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $executePgm
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $argument
$pinfo.WorkingDirectory = $workingDir
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()

return $p
}

$fileSelectBtn.Add_Click({

$selectFilePath.Text = $dialog.FileName
if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
$fileSelect.Text = $dialog.FileName
}
})

$fileUploadBtn.Add_Click({
if ([System.Windows.Forms.MessageBox]::Show("アップロードを行いますか?","アップロード","YesNo") -eq [System.Windows.Forms.DialogResult]::YES) {
uploadFunc $fileSelect.Text
}
})

$comboBox.Add_SelectionChanged({
$listView.ItemsSource = @($comboBox.SelectedItem.請求内訳)
})

$useridPasswordBtn.Add_Click({
if ([System.Windows.Forms.MessageBox]::Show("ユーザID、パスワードの設定を行いますか?","ユーザID・パスワード設定","YesNo") -eq [System.Windows.Forms.DialogResult]::YES) {
if ($userid.Text -eq "") {
[System.Windows.Forms.MessageBox]::Show("ユーザIDを入力してください。","エラー","OK","Error")
return
}
if ($password.Password -eq "") {
[System.Windows.Forms.MessageBox]::Show("パスワードを入力してください。","エラー","OK","Error")
return
}
if ($proxyUserid.Text -eq "") {
[System.Windows.Forms.MessageBox]::Show("プロキシユーザIDを入力してください。","エラー","OK","Error")
return
}
if ($proxyPassword.Password -eq "") {
[System.Windows.Forms.MessageBox]::Show("プロキシパスワードを入力してください。","エラー","OK","Error")
return
}

Set-Item env:JAVA_HOME -Value "C:\Program Files (x86)\Java\jre1.8.0_171"
## パスワード暗号化
$argument = "/c encrypt.bat -e " + $password.Password
$p = processExecute "cmd.exe" $argument "C:\Program Files (x86)\salesforce.com\Data Loader\bin"
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
Write-Host "stdout: $stdout"
Write-Host "stderr: $stderr"
Write-Host "exit code: " + $p.ExitCode

## プロキシパスワード暗号化
$argument = "/c encrypt.bat -e " + $proxyPassword.Password
$p = processExecute "cmd.exe" $argument "C:\Program Files (x86)\salesforce.com\Data Loader\bin"
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
Write-Host "stdout: $stdout"
Write-Host "stderr: $stderr"
Write-Host "exit code: " + $p.ExitCode
}
})

$comboBoxCfg.Add_SelectionChanged({
$datagrid.ItemsSource = @($comboBoxCfg.SelectedItem.請求内訳)
})

$configUpdateBtn.Add_Click({
if ([System.Windows.Forms.MessageBox]::Show("請求内訳の単価を更新しますか?","請求内訳更新","YesNo") -eq [System.Windows.Forms.DialogResult]::YES) {
$configJson = $path + "\" + $CONFIGJSON_FILE

ConvertTo-Json -Depth 4 $obj | Out-File -FilePath $configJson -Encoding utf8
$listView.ItemsSource = @($comboBox.SelectedItem.請求内訳)
}
})

$form.ShowDialog()


<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="コンボボックス with PowerShell" Width="500"
Height="300"
>
<TabControl>
<TabItem Header="CSVアップロード">
<Canvas>
<Label Content="契約顧客" Width="80" Margin="12,12,0,0">
</Label>
<ComboBox Name="Combo1" Margin="82,12,0,0">
</ComboBox>
<Button Content="ファイル選択" Height="23" Width="100" Name="fileSelectBtn" Margin="12,50,0,0">
</Button>
<Button Content="アップロード" Height="23" Width="100" Name="uploadBtn" Margin="132,50,0,0">
</Button>
<TextBox Text="" Width="340" Margin="12,80,0,0" Name="selectFilePath" IsReadOnly="True"
TextWrapping="Wrap" BorderThickness="0" >
</TextBox>
<ListView Name="listView" Margin="12,110,0,0" Height="100">

<GridView>
<GridViewColumn Header="請求内訳名" DisplayMemberBinding="{Binding 請求内訳名}" Width="300"/>
<GridViewColumn Header="仕入単価" DisplayMemberBinding="{Binding 仕入単価}" Width="70"/>
<GridViewColumn Header="請求単価" DisplayMemberBinding="{Binding 請求単価}" Width="70"/>
</GridView>

</ListView>
</Canvas>
</TabItem>
<TabItem Header="初期設定">
<Canvas>
<Label Content="ユーザID" Width="100" Margin="12,12,0,0">
</Label>
<TextBox Text="" Width="340" Margin="122,15,0,0" Name="userId" >
</TextBox>
<Label Content="パスワード" Width="100" Margin="12,52,0,0">
</Label>
<PasswordBox Width="340" Margin="122,55,0,0" Name="password" >
</PasswordBox>
<Label Content="プロキシユーザID" Width="100" Margin="12,92,0,0">
</Label>
<TextBox Text="" Width="340" Margin="122,95,0,0" Name="proxyUserId" >
</TextBox>
<Label Content="プロキシパスワード" Width="100" Margin="12,132,0,0">
</Label>
<PasswordBox Width="340" Margin="122,135,0,0" Name="proxyPassword" >
</PasswordBox>
<Button Content="ユーザID・パスワード設定" Height="23" Width="150" Name="useridPasswordBtn" Margin="12,175,0,0">
</Button>
</Canvas>
</TabItem>
<TabItem Header="請求内訳">
<Canvas>
<Label Content="契約顧客" Width="80" Margin="12,12,0,0">
</Label>
<ComboBox Name="ComboConfig" Margin="82,12,0,0">
</ComboBox>
<DataGrid Name="datagrid" AutoGenerateColumns="False" HorizontalAlignment="Left" Margin="12,50,0,0" Width="450">

<DataGridTextColumn Header="請求内訳名" Binding="{Binding 請求内訳名}" Width="240" IsReadOnly="true"/>
<DataGridTextColumn Header="仕入単価" Binding="{Binding 仕入単価}" Width="Auto"/>
<DataGridTextColumn Header="請求単価" Binding="{Binding 請求単価}" Width="Auto"/>
<DataGridCheckBoxColumn Header="請求除外フラグ" Binding="{Binding 請求単価}" Width="Auto" IsReadOnly="true"/>

</DataGrid>
<Button Content="更新" Height="23" Width="150" Name="configUpdateBtn" Margin="12,175,0,0">
</Button>
</Canvas>
</TabItem>
</TabControl>


</Window>


powershell3

2018-07-01 03:40:13 | powershell
#定数宣言
Set-Variable -name XAML_FILE -value "combo.xaml" -Option Constant -Scope script
Set-Variable -name CSVOUTPUT_FILE -value "output.csv" -Option Constant -Scope script

$Datas = @()


$path = $MyInvocation.MyCommand.Path | Split-Path -Parent
$xaml = [System.IO.File]::ReadAllText($path + "\" + $XAML_FILE, [System.Text.Encoding]::UTF8)
$form = [System.Windows.Markup.XamlReader]::Parse($xaml)

$comboBox = $form.FindName("Combo1")
$configJson = $path + "\config.json"
$obj = Get-Content $configJson -Encoding UTF8 -Raw | ConvertFrom-Json

$outputFilePath = $path +"\" + $CSVOUTPUT_FILE

# fill the combobox with some powershell objects
$comboBox.ItemsSource = $obj.契約顧客リスト
# tell the combobox to use the property "DisplayName" to display the object in its list
$comboBox.DisplayMemberPath = 'Name'
$comboBox.SelectedValuePath = "Id"
# tell the combobox to preselect the first element
$comboBox.SelectedIndex = 0

$listView = $form.FindName("listView")
$listView.ItemsSource = @($comboBox.SelectedItem.請求内訳)

$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = "CSVファイル(*.csv)|*.csv"
$dialog.Title = "ファイルを選択してください。"
$fileSelectBtn = $form.FindName("fileSelectBtn")
$selectFilePath = $form.FindName("selectFilePath")
$fileSelect = $form.FindName("selectFilePath")
$fileUploadBtn = $form.FindName("uploadBtn")

$userid = $form.FindName("userId")
$password = $form.FindName("password")
$proxyUserid = $form.FindName("proxyUserId")
$proxyPassword = $form.FindName("proxyPassword")
$useridPasswordBtn = $form.FindName("useridPasswordBtn")


function uploadFunc($inputFilePath) {

$parms = "/c " + $path + "\test.bat"
$inputObject = Start-Process -FilePath cmd.exe -ArgumentList $parms -PassThru
Wait-Process -InputObject $inputObject

$parms = "/c " + $path + "\test2.bat"
$inputObject = Start-Process -FilePath cmd.exe -ArgumentList $parms -PassThru
Wait-Process -InputObject $inputObject



}

function processExecute( $executePgm, $argument, $workingDir) {

$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $executePgm
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $argument
$pinfo.WorkingDirectory = $workingDir
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()

return $p
}

$fileSelectBtn.Add_Click({

$selectFilePath.Text = $dialog.FileName
if ($dialog.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) {
$fileSelect.Text = $dialog.FileName
}
})

$fileUploadBtn.Add_Click({
if ([System.Windows.Forms.MessageBox]::Show("アップロードを行いますか?","アップロード","YesNo") -eq [System.Windows.Forms.DialogResult]::YES) {
uploadFunc $fileSelect.Text
}
})

$comboBox.Add_SelectionChanged({
$listView.ItemsSource = @($comboBox.SelectedItem.請求内訳)
})

$useridPasswordBtn.Add_Click({
if ([System.Windows.Forms.MessageBox]::Show("ユーザID、パスワードの設定を行いますか?","ユーザID・パスワード設定","YesNo") -eq [System.Windows.Forms.DialogResult]::YES) {
if ($userid.Text -eq "") {
[System.Windows.Forms.MessageBox]::Show("ユーザIDを入力してください。","エラー","OK","Error")
return
}
if ($password.Password -eq "") {
[System.Windows.Forms.MessageBox]::Show("パスワードを入力してください。","エラー","OK","Error")
return
}
if ($proxyUserid.Text -eq "") {
[System.Windows.Forms.MessageBox]::Show("プロキシユーザIDを入力してください。","エラー","OK","Error")
return
}
if ($proxyPassword.Password -eq "") {
[System.Windows.Forms.MessageBox]::Show("プロキシパスワードを入力してください。","エラー","OK","Error")
return
}

Set-Item env:JAVA_HOME -Value "C:\Program Files (x86)\Java\jre1.8.0_171"
## パスワード暗号化
$argument = "/c encrypt.bat -e " + $password.Password
$p = processExecute "cmd.exe" $argument "C:\Program Files (x86)\salesforce.com\Data Loader\bin"
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
Write-Host "stdout: $stdout"
Write-Host "stderr: $stderr"
Write-Host "exit code: " + $p.ExitCode

## プロキシパスワード暗号化
$argument = "/c encrypt.bat -e " + $proxyPassword.Password
$p = processExecute "cmd.exe" $argument "C:\Program Files (x86)\salesforce.com\Data Loader\bin"
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
Write-Host "stdout: $stdout"
Write-Host "stderr: $stderr"
Write-Host "exit code: " + $p.ExitCode
}
})

$form.ShowDialog()

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="コンボボックス with PowerShell" Width="500"
Height="300"
>
<TabControl>
<TabItem Header="CSVアップロード">
<Canvas>
<Label Content="契約顧客" Width="80" Margin="12,12,0,0">
</Label>
<ComboBox Name="Combo1" Margin="82,12,0,0">
</ComboBox>
<Button Content="ファイル選択" Height="23" Width="100" Name="fileSelectBtn" Margin="12,50,0,0">
</Button>
<Button Content="アップロード" Height="23" Width="100" Name="uploadBtn" Margin="132,50,0,0">
</Button>
<TextBox Text="" Width="340" Margin="12,80,0,0" Name="selectFilePath" IsReadOnly="True"
TextWrapping="Wrap" BorderThickness="0" >
</TextBox>
<ListView Name="listView" Margin="12,110,0,0" Height="100">

<GridView>
<GridViewColumn Header="請求内訳名" DisplayMemberBinding="{Binding 請求内訳名}" Width="300"/>
<GridViewColumn Header="仕入単価" DisplayMemberBinding="{Binding 仕入単価}" Width="70"/>
<GridViewColumn Header="請求単価" DisplayMemberBinding="{Binding 請求単価}" Width="70"/>
</GridView>

</ListView>
</Canvas>
</TabItem>
<TabItem Header="初期設定">
<Canvas>
<Label Content="ユーザID" Width="100" Margin="12,12,0,0">
</Label>
<TextBox Text="" Width="340" Margin="122,15,0,0" Name="userId" >
</TextBox>
<Label Content="パスワード" Width="100" Margin="12,52,0,0">
</Label>
<PasswordBox Width="340" Margin="122,55,0,0" Name="password" >
</PasswordBox>
<Label Content="プロキシユーザID" Width="100" Margin="12,92,0,0">
</Label>
<TextBox Text="" Width="340" Margin="122,95,0,0" Name="proxyUserId" >
</TextBox>
<Label Content="プロキシパスワード" Width="100" Margin="12,132,0,0">
</Label>
<PasswordBox Width="340" Margin="122,135,0,0" Name="proxyPassword" >
</PasswordBox>
<Button Content="ユーザID・パスワード設定" Height="23" Width="150" Name="useridPasswordBtn" Margin="12,175,0,0">
</Button>
</Canvas>
</TabItem>
</TabControl>


</Window>

{
"契約顧客リスト": [
{"Id":1, "Name":"XXXXXXXXXXX(株)",
"請求内訳": [
{"内訳コード":"010", "請求内訳コード":"2420", "請求内訳名":"XXXXXXXXXXXXX", "仕入単価":6, "請求単価":8, "請求除外":"false"},
{"内訳コード":"010", "請求内訳コード":"2420", "請求内訳名":"XXXXXXXXXXXXX", "仕入単価":13, "請求単価":16, "請求除外":"false"}
]
},
{"Id":2, "Name":"XXXXXXXXXXX(株)",
"請求内訳": [
{"内訳コード":"010", "請求内訳コード":"2420", "請求内訳名":"XXXXXXXXXXXXX", "仕入単価":6, "請求単価":8, "請求除外":"false"},
{"内訳コード":"010", "請求内訳コード":"2420", "請求内訳名":"XXXXXXXXXXXXX", "仕入単価":13, "請求単価":18, "請求除外":"false"}
]
}
]
}


powershell 2

2018-06-21 02:12:28 | powershell
function Execute-SOAPRequest
(
[Xml] $SOAPRequest,
[String] $URL
)
{
#通信設定
write-host "Sending SOAP Request To Server: $URL"
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction","`"`"")

$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Accept = "text/xml"
$soapWebRequest.Method = "POST"

#リクエスト送信
write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()
$SOAPRequest.Save($requestStream)
$requestStream.Close()

#レスポンス獲得
write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()
$responseStream.Close()

write-host "Response Received."

return $ReturnXml
}
[xml]$soap =
'
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<n1:login xmlns:n1="urn:partner.soap.sforce.com">
<n1:username>xxxxxxxxx</n1:username>
<n1:password>xxxxxxxxxx</n1:password>
</n1:login>
</env:Body>
</env:Envelope>'

$url = 'https://login.salesforce.com/services/Soap/u/43.0'
#呼び出し
$xml = Execute-SOAPRequest $soap $url

$ns = New-Object Xml.XmlNamespaceManager $xml.NameTable
$ns.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/")

$node = $xml.SelectSingleNode('/soapenv:Body/loginResponse/result/sessionId', $ns)

$xml.OuterXml -match '^.*\(.+)\.*$'
$sessionId = $matches[1]
$url = "https://xxx.salesforce.com/services/data/v43.0/sobjects/Account"

Invoke-RestMethod -Uri $url -Headers @{Authorization = "Bearer " + $sessionId}

powershell 1

2018-06-19 01:05:47 | powershell
●script
#定数宣言
Set-Variable -name XAML_FILE -value "combo.xaml" -Option Constant -Scope script


$path = $MyInvocation.MyCommand.Path | Split-Path -Parent
$xaml = [System.IO.File]::ReadAllText($path + "\" + $XAML_FILE, [System.Text.Encoding]::UTF8)
$form = [System.Windows.Markup.XamlReader]::Parse($xaml)

$comboBox = $form.FindName("Combo1")
$configJson = $path + "\config.json"
$obj = Get-Content $configJson -Encoding UTF8 -Raw | ConvertFrom-Json

# fill the combobox with some powershell objects
$comboBox.ItemsSource = $obj.契約顧客リスト
# tell the combobox to use the property "DisplayName" to display the object in its list
$comboBox.DisplayMemberPath = 'Name'
$comboBox.SelectedValuePath = "Id"
# tell the combobox to preselect the first element
$comboBox.SelectedIndex = 0

$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = "CSVファイル(*.csv)|*.csv"
$dialog.Title = "ファイルを選択してください。"
$fileSelectBtn = $form.FindName("fileSelectBtn")

$selectFilePath = $form.FindName("selectFilePath")

$fileSelectBtn.Add_Click({
$dialog.ShowDialog()
$selectFilePath.Text = $dialog.FileName
})

#$comboBox.ItemsSource = "Tokyo","Osaka","Nagoya","Kyoto"
$form.ShowDialog()

●xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="コンボボックス with PowerShell" Width="370"
Height="200"
>
<Canvas>
<Label Content="契約顧客" Width="80" Margin="12,12,0,0">
</Label>
<ComboBox Name="Combo1" Margin="82,12,0,0">
</ComboBox>
<Button Content="ファイル選択" Height="23" Width="100" Name="fileSelectBtn" Margin="12,50,0,0">
</Button>
<Button Content="アップロード" Height="23" Width="100" Name="uploadBtn" Margin="132,50,0,0">
</Button>
<TextBox Text="" Width="340" Margin="12,80,0,0" Name="selectFilePath" IsReadOnly="True"
TextWrapping="Wrap" BorderThickness="0" >
</TextBox>
</Canvas>


</Window>

●json
{
"契約顧客リスト": [
{"Id":1, "Name":"テスト1(株)"},
{"Id":2, "Name":"テスト2(株)"}
]
}

二つのファイル更新日時計算

2018-04-12 23:28:56 | Shell
#!/bin/sh
FROM_FILE=/var/log/maillog
TO_FILE=/var/log/messages
basis=300
if [ $# -gt 0 ]; then
basis=$1
fi
fromTime=`stat -c '%y' "${FROM_FILE}"`
toTime=`stat -c '%y' "${TO_FILE}"`
diff=$(expr `date -d"${toTime}" +%s` - `date -d"${fromTime}" +%s`)

if [ ${diff} -gt ${basis} ]; then
exit 1
fi
exit 0

db2 再帰sql

2016-04-16 03:10:12 | JavaScript
with p (org_id, APPROVAL_REVEL, USER_ID, user_name, APPROVAL_USER, APPROVAL_name, level )
as (
select
t1.USER_ID as org_id, t1.APPROVAL_REVEL, t1.USER_ID, t1.user_name, t1.APPROVAL_USER, t2.USER_NAME as APPROVAL_name
,0 as level
from t_user t1 left outer join t_user t2
on t1.APPROVAL_USER = t2.USER_ID
where t1.USER_ID = 1
union all
select
p.org_id,
c.*,
p.level +1 as level
from
(
select
s1.APPROVAL_REVEL, s1.USER_ID, s1.user_name, s1.APPROVAL_USER, s2.USER_NAME as APPROVAL_name
from t_user s1 left outer join t_user s2
on s1.APPROVAL_USER = s2.USER_ID
) c, p
where
p.APPROVAL_USER = c.USER_ID and p.APPROVAL_USER <> 1)
select * from p
order by APPROVAL_REVEL

記事のタイトルを入力してください(必須)

2016-04-05 00:15:43 | JavaScript
JavaScript 小数点チェック

function numberFormatCheck(element) {

	element.classList.remove("errorColor");
	//未入力時はチェックしない。
	if (! element &&! element.value && element.value != 0) {
		return true;
	}

	if (! element.value.match(/^[\.0-9]+$/)) {
		alert ("不正な文字が含まれています。");
		element.classList.add("errorColor");
		return false;
	}

	if (! element.value.match(/^[0-9]+\.[0-9]{0,1}$/) && ! element.value.match(/^[0-9]+$/)) {
		alert ("形式が正しくありません。");
		element.classList.add("errorColor");
		return false;
	}

	return true;
}

Java 正規表現 パスワードで英大文字、英小文字、数字、記号のうち、3種類で8文字以上

2015-11-27 22:20:12 | 正規表現

こんな感じ



String pattern =
"^("
+ "(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])" //英小文字、英大文字、数字
+ "|"
+ "(?=.*[a-z])(?=.*[A-Z])(?=.*[!-/:-@\\[-`{-~])" //英小文字、英大文字、記号
+ "|"
+ "(?=.*[a-z])(?=.*[0-9])(?=.*[!-/:-@\\[-`{-~])" //英小文字、数字、記号
+ "|"
+ "(?=.*[A-Z])(?=.*[0-9])(?=.*[!-/:-@\\[-`{-~])" //英大文字、数字、記号
+ ")"
+ "[a-zA-Z0-9!-/:-@\\[-`{-~]{8,}$"; //英大文字、英小文字、数字、記号8文字以上

Weblogic9.2 WebサービスでExceptionInInitializerError

2009-10-12 04:55:42 | WebLogic
Weblogic 9.2でcilentgenでスタブを作成して、webサービスを呼び出す簡単なpojoを作成したところ、java.lang.ExceptionInInitializerErrorが発生!

原因と対策)
weblogic-container-binding.jarとweblogic.jarで、fullyqualifiedclasstyped2a5type.xsb がコンフリクトしていて、駄目らしい。
(weblogic-container-binding.jarのほうが古い。)
クラスパス上で、weblogic.jarを先にしたところ、解決した。