tag:blogger.com,1999:blog-76380632005006409612024-03-08T06:31:48.364+01:00notes-jjAnonymoushttp://www.blogger.com/profile/06803366747697181996noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7638063200500640961.post-49560663065989397072016-05-30T00:17:00.000+02:002016-05-30T00:19:03.953+02:00Docker InfluxDB: Create Container with HTTP AuthentictationThe official Docker <a href="https://hub.docker.com/_/influxdb/">InfluxDB</a> container will not start with authentication. In InfluxDB 0.13.0 the ability to control the config via <a href="https://github.com/influxdata/influxdb/pull/6444">Environment Variables</a> was added. The easiest way to create a container with http authentication and creating an admin user is:
<br />
<br />
<h4>
Create Container and set Admin User and Password</h4>
<pre><code class="bash"># Create temp Container
docker run -d \
--name test-influx \
-p 8083:8083 -p 8086:8086 \
-e INFLUXDB_HTTP_AUTH_ENABLED="true" \
influxdb:0.13.0-alpine
# Create admin user in InfluxDB
docker exec -ti test-influx \
/usr/bin/influx -execute "CREATE USER admin WITH PASSWORD 'pass' WITH ALL PRIVILEGES; SHOW USERS"
</code></pre>
<h4>Accessing the InfluxDB Console from Shell</h4>
The influx console has to be accessed with username and password from now on.
<br />
<pre><code class="bash">docker exec -ti test-influx \
/usr/bin/influx -username 'admin' -password 'pass'
</code></pre>
<h4>Bug: Empty password</h4>
There is a bug right now with leaving the password empty, to ge a prompt:
<a href="https://github.com/influxdata/influxdb/issues/6746">[Bug] Empty Password for Prompt not working (/usr/bin/influx) #6746</a>Anonymoushttp://www.blogger.com/profile/06803366747697181996noreply@blogger.com0tag:blogger.com,1999:blog-7638063200500640961.post-3301725481075217052016-05-29T14:37:00.000+02:002016-05-29T14:37:46.782+02:00LotusScript: Easy and Fast @ReplaceSubstring AlternativeOn the first glimpse, there is no direct way to do a replace substring in LotusScript like in formula using @ReplaceSubstring. Even the <a href="http://www-01.ibm.com/support/docview.wss?uid=swg21102507">IBM Technote #1102507</a> suggests using "instr", "left" and "mid".<br />
<br />
There is a much faster and easy way to use accomplish this task by using the function replace:<br />
<blockquote class="tr_bq">
Replace(sourceArray, findArray, replacementArray [, start [, count [, compMethod]]])</blockquote>
<b>This function also works for strings.<br /></b>
<br />
The code is even faster too:
<br />
<ul>
<li>3773 ms - FindReplace_IBM</li>
<li>2719 ms - FindReplace_Tuned</li>
<li><b>539 ms - Replace</b></li>
<li>1469 ms - Replace on Array</li>
<li>7473 ms - FindReplace_IBM - 2 Values</li>
<li>6688 ms - FindReplace_Tuned - 2 Values</li>
<li><b>1102 ms - Replace - 2 Values</b></li>
<li>1871 ms - Replace on Array - 2 Values</li>
</ul>
<br />
<h4>Demo Code: Usage Replace</h4>
<pre><code class="VBScript">Sub Initialize
Dim result As Variant
' Replace single Value
result = Replace ("alice bar alicebar", "alice", "foo")
Print "1: " + result ' result = "foo bar foobar"
' Replace two Values
result = Replace ("alice bob alicebob", _
Split("alice bob"), Split("foo bar"))
Print "2: " + result ' result = "foo bar foobar"
' Replace two Values, with one
result = Replace ("alice bar bobbar", Split("alice bob"), "foo")
Print "3: " + result ' result = "foo bar foobar"
' If replacmentArray is larger than findArray,
' the Values will be ignored
result = Replace ("alice bar bobbar", _
Split("alice bob"), Split("foo foo bar"))
Print "4: " + result ' result = "foo bar foobar"
' For Replacing Blank use Delimiter in Split
result = Replace ("alice bar alice bar", _
Split("alice: ",":"), Split("foo:",":"))
Print "5: " + result ' result = "foo bar foobar"
' Multi Level Replacments
' "alicebob bar bobbobbar" -> "bobbob bar bobbobbar"
' "bobbob bar bobbobbar" -> "foo bar foobar"
result = Replace ("alicebob bar bobbobbar", _
Split("alice bobbob"), Split("bob foo"))
Print "6: " + result ' result = "foo bar foobar"
Dim resultArray As Variant
' Replace Array Substring
resultArray = Replace(Split("alice bob alicebob"), _
Split("alice bob"), Split("foo bar"))
Print "6: " + "[""" + Join(resultArray,""", """) + """]"
' resultArray = "["foo", "bar", "foobar"]"
End Sub
</code></pre>
<h4>Demo Code: Perfomance</h4>
<pre><code class="VBScript">Option Public
Option Declare
Sub Initialize
Const LOOP_MAX = 100000
Dim i As Long
Dim timerStart As Single
Dim timerResult As Single
Dim result As Variant
Dim resultArray As Variant
' Classic IBM Method
TimerStart = Timer
For i = 1 To LOOP_MAX
result = FindReplace_IBM("faa bar faabar faa bar faabar faa bar faabar", "aa", "oo")
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - FindReplace_IBM " + " - Result: " + result
' IBM Method tuned
TimerStart = Timer
For i = 1 To LOOP_MAX
result = FindReplace_Tuned("faa bar faabar faa bar faabar faa bar faabar", "aa", "oo")
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - FindReplace_Tuned " + " - Result: " + result
' Replace
TimerStart = Timer
For i = 1 To LOOP_MAX
result = Replace("faa bar faabar faa bar faabar faa bar faabar", "aa", "oo")
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - Replace " + " - Result: " + result
' Replace on Array
TimerStart = Timer
For i = 1 To LOOP_MAX
resultArray = Replace(Split("faa bar faabar faa bar faabar faa bar faabar"), "aa", "oo")
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - Replace on Array " + " - Result: [""" + Join(resultArray,""", """) + """]"
' Classic IBM Method - 2 Values
TimerStart = Timer
For i = 1 To LOOP_MAX
result = FindReplace_IBM("faa bar faabar faa bar faabar faa bar faabar", "aa", "oo")
result = FindReplace_IBM(result, "oo", "uu")
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - FindReplace_IBM - 2 Values " + " - Result: " + result
' IBM Method tuned - 2 Values
TimerStart = Timer
For i = 1 To LOOP_MAX
result = FindReplace_Tuned("faa bar faabar faa bar faabar faa bar faabar", "aa", "oo")
result = FindReplace_IBM(result, "oo", "uu")
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - FindReplace_Tuned - 2 Values " + " - Result: " + result
' Replace - 2 Values
TimerStart = Timer
For i = 1 To LOOP_MAX
result = Replace("faa bar faabar faa bar faabar faa bar faabar", Split("aa oo"), Split("oo uu"))
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - Replace - 2 Values " + " - Result: " + result
' Replace on Array - 2 Values
TimerStart = Timer
For i = 1 To LOOP_MAX
resultArray = Replace(Split("faa bar faabar faa bar faabar faa bar faabar"), Split("aa oo"), Split("oo uu"))
Next
timerResult = (Timer - timerStart) * 1000 ' milliseconds
print Format$(timerResult, "###0") + " ms - Replace on Array - 2 Values " + " - Result: [""" + Join(resultArray,""", """) + """]"
End Sub
Function FindReplace_IBM (ByVal wholestring As Variant, find As String, ireplace As String) As String
' Source http://www-01.ibm.com/support/docview.wss?uid=swg21102507
Dim checkstring, saveleft, leftstring, rightstring As String
Dim n As Integer
checkstring=wholestring
saveleft=""
While InStr(1, checkstring, find) <> 0
n=InStr(1, checkstring, find)
leftstring = Left(checkstring, n-1)
rightstring=Right(checkstring, Len(checkstring)-n-Len(find)+1)
saveleft=saveleft+leftstring+ireplace
checkstring=rightstring
Wend
FindReplace_IBM = saveleft+checkstring
End Function
Function FindReplace_Tuned (paraString As String, paraFrom As String, paraTo As String) As String
' IBM Method tuned
Dim result As String
result = paraString
While InStr(result, paraFrom) <> 0
result = Left(result, InStr(result, paraFrom) - 1) & paraTo & Mid(result, InStr(result, paraFrom) + Len(paraFrom))
Wend
FindReplace_Tuned = result
End Function
</code></pre>Anonymoushttp://www.blogger.com/profile/06803366747697181996noreply@blogger.com0