<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Theo</title>
    <description>The latest articles on DEV Community by Theo (@tios).</description>
    <link>https://dev.to/tios</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F242027%2F6fefbd9c-a19c-4587-b7be-fdafe45dbfdf.png</url>
      <title>DEV Community: Theo</title>
      <link>https://dev.to/tios</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tios"/>
    <language>en</language>
    <item>
      <title>MongoDB equivalent of SQL LIKE query</title>
      <dc:creator>Theo</dc:creator>
      <pubDate>Wed, 01 Sep 2021 13:54:24 +0000</pubDate>
      <link>https://dev.to/tios/mongodb-equivalent-of-sql-like-query-4keg</link>
      <guid>https://dev.to/tios/mongodb-equivalent-of-sql-like-query-4keg</guid>
      <description>&lt;p&gt;A quick snippet for anyone looking for equivalent SQL LIKE queries for mongodb.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;db.users.find({name: /a/}) 
SELECT * FROM USERS WHERE name LIKE '%a%';

db.users.find({name: /^ja/}) 
SELECT * FROM USERS WHERE name LIKE 'ja%'

db.users.find({name: /jo$/}) 
SELECT * FROM USERS WHERE name LIKE '%jo'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>mongodb</category>
      <category>sql</category>
      <category>regex</category>
    </item>
    <item>
      <title>Quick LoadTests with Artillery</title>
      <dc:creator>Theo</dc:creator>
      <pubDate>Wed, 13 May 2020 21:23:50 +0000</pubDate>
      <link>https://dev.to/tios/quick-loadtests-with-artillery-1g65</link>
      <guid>https://dev.to/tios/quick-loadtests-with-artillery-1g65</guid>
      <description>&lt;p&gt;I was troubleshooting a capacity issue with one of the web application and wanted to reproduce why some calls were failing. Usually I turn to Jmeter but today I decided to use something quick and fast and found this nifty nodejs called Artillery. Just configure what you wanted to do in a yml file and run the test. You will get report of the http responses and various other stats.&lt;/p&gt;

&lt;p&gt;I found it very useful to make a quick number of requests along with request chaining and authentication. Here is what I did.&lt;/p&gt;

&lt;p&gt;To install&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add global artillery
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now create a yml file as below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config:
  target: 'https://api.edge.service'
  phases:
   - duration: 30
     arrivalRate: 1
scenarios:
 - flow:
   - log: "Getting token"
   - post:
      url: "/token"
      json:
       username: 'xxxxxx'
       password: 'xxxxxxxx'
       grant_type: 'password'
      capture:
       json: "$.access_token"
       as: access_token
      expect:
        - statusCode: 200
   - get:
      headers:
        Authorization: 'Bearer {{ access_token }}'
      url: "/apis/users/v1"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above yml is self explanatory. But in brief, here is what it does, it has a base url of '&lt;a href="https://api.edge.service"&gt;https://api.edge.service&lt;/a&gt;' and the test will run for 30 seconds with 1 user request being made every second. It will first make a token request and uses the 'access_token' field in the response json in the next request's 'Authorization' header. &lt;/p&gt;

&lt;p&gt;So there you have it, a request which first gets an authentication token and then using that token to make another API call.&lt;/p&gt;

&lt;p&gt;Run the test&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#  With debug to see the requests made.
DEBUG=http artillery run load.yml

#  With debug to see the requests and responses made.
DEBUG=http:response artillery run load.yml

#  With debug to see the requests and responses made.
DEBUG=http:response artillery run load.yml

#Or just run in default mode
artillery run load-dev.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Report&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Summary report @ 17:20:54(-0400) 2020-05-13
  Scenarios launched:  1
  Scenarios completed: 1
  Requests completed:  2
  Mean response/sec: 1.35
  Response time (msec):
    min: 45.5
    max: 1126.6
    median: 586.1
    p95: 1126.6
    p99: 1126.6
  Scenario counts:
    0: 1 (100%)
  Codes:
    200: 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The more I read the documentation of Artillery, the more I like it. It also has a PRO version which is paid and can be run from cloud. For me, I just use it my local to run some quick tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://artillery.io/docs/getting-started"&gt;https://artillery.io/docs/getting-started&lt;/a&gt;&lt;/p&gt;

</description>
      <category>loadtest</category>
      <category>httptest</category>
      <category>performancetests</category>
      <category>artillery</category>
    </item>
    <item>
      <title>Quick start to GraalVM</title>
      <dc:creator>Theo</dc:creator>
      <pubDate>Thu, 03 Oct 2019 15:20:54 +0000</pubDate>
      <link>https://dev.to/tios/quick-start-to-graalvm-3p1a</link>
      <guid>https://dev.to/tios/quick-start-to-graalvm-3p1a</guid>
      <description>&lt;p&gt;This post is a TLDR; of &lt;a href="https://www.graalvm.org/docs/getting-started/"&gt;Getting started with GraalVM&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally Java can go real native without the bloat of commerical "native" compilers like ExcelsiorJet or Launchers like Launch4J. Meet GraalVM. With native-image you can AOT (Ahead of time) compile your java code to native executable. When I mean native executable, I mean real native executable unlike Launch4j which embeds a jre or prompts you to get one.&lt;/p&gt;

&lt;p&gt;Here is a quick HelloWorld to get started.&lt;br&gt;
Since it is a quick HelloWorld, we dont want to rock the boat by messing up our existing JDK installation. So we will use docker in Windows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it -v C:/graalexp:/home/graalexp oracle/graalvm-ce:19.2.0.1 bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;C:/graalexp&lt;/code&gt; - is your windows mount. [ Remember to share your C drive with docker in settings]&lt;/p&gt;

&lt;p&gt;With a notepad write a &lt;code&gt;HelloWorld.java&lt;/code&gt; in &lt;code&gt;C:/graalexp&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, Graal!");
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install native-image in the docker container as its not installed by default in graalvm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gu install native-image
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now compile it to native image. The native image will run on linux targets. If you want native executables to run on windows, its a bit different than the steps listed here.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javac HelloWorld.java
native-image HelloWorld
./helloworld
Hello, Graal!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats it.&lt;br&gt;
Note: Graal has commerical as well as community editions. We are using community edition here.&lt;/p&gt;

</description>
      <category>graalvm</category>
      <category>java</category>
    </item>
  </channel>
</rss>
