<?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: Sufiyan</title>
    <description>The latest articles on DEV Community by Sufiyan (@sufiyanyusuf).</description>
    <link>https://dev.to/sufiyanyusuf</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%2F713299%2F64aea289-3ba9-47fa-996c-0d565cdc7536.jpeg</url>
      <title>DEV Community: Sufiyan</title>
      <link>https://dev.to/sufiyanyusuf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sufiyanyusuf"/>
    <language>en</language>
    <item>
      <title>Generating a non-random UUID, using a hash of multiple strings in Swift</title>
      <dc:creator>Sufiyan</dc:creator>
      <pubDate>Thu, 03 Aug 2023 02:35:30 +0000</pubDate>
      <link>https://dev.to/sufiyanyusuf/generating-a-non-random-uuid-using-a-hash-of-2-strings-in-swift-cp4</link>
      <guid>https://dev.to/sufiyanyusuf/generating-a-non-random-uuid-using-a-hash-of-2-strings-in-swift-cp4</guid>
      <description>&lt;p&gt;I was just working with some messy data, and realized I need a deterministic way to generate UUIDs from 2 strings in an iOS project. Looks like the only standard method available is &lt;/p&gt;

&lt;p&gt;&lt;code&gt;UUID(uuidString: String)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The problem with this is sometimes we don't have the formatted uuidString, so turns out we need to build it ourselves.&lt;/p&gt;

&lt;p&gt;Enough talk, here's the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Foundation
import CommonCrypto

func createHash(from string1: String, and string2: String) -&amp;gt; Data {
    let concatenatedString = string1 + string2
    guard let data = concatenatedString.data(using: .utf8) else {
        return Data()
    }

    var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
    _ = data.withUnsafeBytes {
        CC_SHA256($0.baseAddress, UInt32(data.count), &amp;amp;digest)
    }

    return Data(digest)
}

func generateNonRandomUUID(from string1: String, and string2: String) -&amp;gt; UUID {
    let hashData = createHash(from: string1, and: string2)

    // Truncate the hash data to 128 bits (16 bytes)
    let truncatedHashData = hashData.prefix(16)

    // Create a byte array (UnsafePointer&amp;lt;UInt8&amp;gt;) from the truncated hash data
    var byteArray: [UInt8] = []
    truncatedHashData.withUnsafeBytes {
        byteArray.append(contentsOf: $0)
    }

    // Create a UUID from the byte array
    let uuid = NSUUID(uuidBytes: byteArray)

    return uuid as UUID
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>uuid</category>
      <category>swift</category>
      <category>swiftui</category>
      <category>hash</category>
    </item>
    <item>
      <title>Focused state border width hack with Elm-UI</title>
      <dc:creator>Sufiyan</dc:creator>
      <pubDate>Thu, 21 Oct 2021 04:49:58 +0000</pubDate>
      <link>https://dev.to/sufiyanyusuf/focused-state-border-width-hack-with-elm-ui-3n5b</link>
      <guid>https://dev.to/sufiyanyusuf/focused-state-border-width-hack-with-elm-ui-3n5b</guid>
      <description>&lt;p&gt;I was recently trying to fix the focused styling for textfields in our company design system (&lt;a href="https://github.com/PaackEng/paack-ui"&gt;https://github.com/PaackEng/paack-ui&lt;/a&gt;), and ran into this issue where I wasn't able to update the border width as per the design for the focused state. &lt;/p&gt;

&lt;p&gt;So elm-ui lets you specify attributes for the focused state, but these have the type "decorative" attr (apparently the decorative label has something to do with the ephemeral styles). &lt;/p&gt;

&lt;p&gt;Unfortunately, border width property has the type attr.  After banging my head for a while I realized a good hack - instead of setting the border width for the focused state, I just ended up setting an explicit shadow:&lt;/p&gt;

&lt;p&gt;shadow { color = Colors.navyBlue700, offset = ( 0, 0 ), blur = 0, size = 1.2 }&lt;/p&gt;

&lt;p&gt;Works perfectly !!!&lt;/p&gt;

</description>
      <category>elm</category>
      <category>elmui</category>
      <category>beginners</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
