<?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: Slothy</title>
    <description>The latest articles on DEV Community by Slothy (@slothy).</description>
    <link>https://dev.to/slothy</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F503699%2F64a9a108-0b58-48e7-b07b-e32c6e9dbf74.jpg</url>
      <title>DEV Community: Slothy</title>
      <link>https://dev.to/slothy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/slothy"/>
    <language>en</language>
    <item>
      <title>Security through obscurity</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Fri, 15 Sep 2023 16:10:53 +0000</pubDate>
      <link>https://dev.to/slothy/security-through-obscurity-321c</link>
      <guid>https://dev.to/slothy/security-through-obscurity-321c</guid>
      <description>&lt;p&gt;Random thought of the day: denial that security through obscurity is a valid technique is itself a layer of security through obscurity 🤯&lt;/p&gt;

</description>
      <category>security</category>
    </item>
    <item>
      <title>Dealing with IDE reformatting (VSCode) Vue templates breaking white space preservation</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Wed, 02 Mar 2022 14:53:38 +0000</pubDate>
      <link>https://dev.to/slothy/dealing-with-ide-reformatting-vscode-vue-templates-breaking-white-space-preservation-35li</link>
      <guid>https://dev.to/slothy/dealing-with-ide-reformatting-vscode-vue-templates-breaking-white-space-preservation-35li</guid>
      <description>&lt;p&gt;I've been recently losing my mind with eslint and Vetur both reformatting blocks that need to not have any whitespace, and finally came up with a much better solution.&lt;/p&gt;

&lt;p&gt;A simple re-usable single file component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;template&amp;gt;
    &amp;lt;div class="preserve"&amp;gt;{{ content }}&amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
export default {
    props: ["content"],
};
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply use this component, without any worry about line length forcing it to break to a new line&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Show 404s from Laravel's telescope directly from DB</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Sat, 19 Feb 2022 13:41:52 +0000</pubDate>
      <link>https://dev.to/slothy/show-404s-from-laravels-telescope-directly-from-db-14lp</link>
      <guid>https://dev.to/slothy/show-404s-from-laravels-telescope-directly-from-db-14lp</guid>
      <description>&lt;p&gt;Not terribly efficient, but if you want to quickly review the recent 404s, will do in a pinch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT json_extract(content, '$.uri') AS uri, created_at 
FROM `telescope_entries` 
WHERE `content` LIKE '%404%' 
ORDER BY `sequence` DESC 
LIMIT 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Setting up Android/Cordova on Mac in 2021</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Fri, 18 Jun 2021 12:22:44 +0000</pubDate>
      <link>https://dev.to/slothy/setting-up-android-cordova-on-mac-in-2021-4c2n</link>
      <guid>https://dev.to/slothy/setting-up-android-cordova-on-mac-in-2021-4c2n</guid>
      <description>&lt;p&gt;The documentation is beyond useless, to setup the directories you'll need this in your ~/.zshrc file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export PATH="${HOME}/Library/Android/sdk/tools:${HOME}/Library/Android/sdk/platform-tools:${PATH}"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can disregard the current documentation, it references .bash_profile which is no longer the default on Mac, and ignores its own instructions about how to setup the paths, thanks Cordova!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>pt-archiver Incorrect date value: '0000-00-00' for column</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Sat, 21 Nov 2020 16:41:58 +0000</pubDate>
      <link>https://dev.to/slothy/pt-archiver-incorrect-date-value-0000-00-00-for-column-2415</link>
      <guid>https://dev.to/slothy/pt-archiver-incorrect-date-value-0000-00-00-for-column-2415</guid>
      <description>&lt;p&gt;This was a weird one. I had a bug that inserted records with &lt;code&gt;0000-00-00&lt;/code&gt; for a short while many years ago on an older version of MySQL.&lt;/p&gt;

&lt;p&gt;The strange thing here, is you can't actually search for the records with &lt;code&gt;0000-00-00&lt;/code&gt; since newer versions of MySQL consider this an invalid date, they reject the query.&lt;/p&gt;

&lt;p&gt;To find the invalid records use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;CAST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dateField&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="nb"&gt;CHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'0000-00-00'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or just fix the problem in one query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;UPDATE&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="n"&gt;dateField&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="k"&gt;CAST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dateField&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="nb"&gt;CHAR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'0000-00-00'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Randomize ElasticSearch results with PHP</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Sat, 14 Nov 2020 15:27:22 +0000</pubDate>
      <link>https://dev.to/slothy/randomize-elasticsearch-results-with-php-551a</link>
      <guid>https://dev.to/slothy/randomize-elasticsearch-results-with-php-551a</guid>
      <description>&lt;p&gt;Simple example of how to re-order your original query and wrap it to randomize the results.&lt;/p&gt;

&lt;p&gt;This is using the official PHP ES library: &lt;a href="https://github.com/elastic/elasticsearch-php"&gt;https://github.com/elastic/elasticsearch-php&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$originalQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'body'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'query'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

    &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'body'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'query'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="s1"&gt;'function_score'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'query'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$originalQuery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'random_score'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="nf"&gt;stdClass&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nv"&gt;$searchRawResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Authorize.net - Validate Webhook Signature</title>
      <dc:creator>Slothy</dc:creator>
      <pubDate>Sun, 01 Nov 2020 12:28:01 +0000</pubDate>
      <link>https://dev.to/slothy/authorize-net-validate-webhook-signature-3ale</link>
      <guid>https://dev.to/slothy/authorize-net-validate-webhook-signature-3ale</guid>
      <description>&lt;p&gt;Couldn't find any complete examples on how to do this, so here is one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nb"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'AUTHORIZE_SIGNATURE_KEY'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'abc123'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nv"&gt;$body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;file_get_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'php://input'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nv"&gt;$headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;getallheaders&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nv"&gt;$header&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'X-ANET-Signature'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nb"&gt;parse_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$header&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// need to match case since PHP will generate the hash as lowercase&lt;/span&gt;
&lt;span class="nv"&gt;$signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;strtolower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$output&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sha512'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="nv"&gt;$hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;hash_hmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha512'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;AUTHORIZE_SIGNATURE_KEY&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$hash&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nv"&gt;$signature&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"signature matches"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>authorize</category>
      <category>php</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
