<?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: kalokli8</title>
    <description>The latest articles on DEV Community by kalokli8 (@kalokli8).</description>
    <link>https://dev.to/kalokli8</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%2F838041%2Faa82db47-cdee-4425-bdd2-c2361bea2eba.png</url>
      <title>DEV Community: kalokli8</title>
      <link>https://dev.to/kalokli8</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kalokli8"/>
    <language>en</language>
    <item>
      <title>LLM Prompting best practices</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Sat, 11 Oct 2025 16:57:58 +0000</pubDate>
      <link>https://dev.to/kalokli8/llm-prompting-best-practices-29ej</link>
      <guid>https://dev.to/kalokli8/llm-prompting-best-practices-29ej</guid>
      <description>&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;This blog post is based on what I learn from 'Introduction to Generative AI for Software Development' from DeepLearning.AI. I think this will be a good revision material for following the best practice of using LLM prompting.&lt;/p&gt;

&lt;p&gt;I have summarized four key strategies for effectively leveraging large language models (LLMs) in software development, based on insights from a recent module. It covers optimal prompting techniques and how developers’ roles evolve when working with LLMs. Below are four main points to guide developers in maximizing the benefits of LLMs while maintaining control over their projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Be Specific in Prompts
&lt;/h3&gt;

&lt;p&gt;To get the most out of an LLM, provide detailed and specific prompts. Include extensive context about your project, such as problem descriptions or large code snippets. LLMs, built on transformer models, can handle substantial amounts of text, so don’t shy away from long prompts. The more precise your input, the more accurate and relevant the LLM’s response will be. Vague queries often lead to generic outputs, so clarity is key.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Assign Roles and Seek Expert Feedback
&lt;/h3&gt;

&lt;p&gt;Assigning a role to the LLM helps tailor its output to your needs. For example, asking it to act as a “helpful coding tutor” might yield beginner-friendly code with detailed comments, while an “expert programmer” role could produce more concise, optimized solutions. Additionally, you can assign the LLM as an expert in domains like software testing or cybersecurity and request feedback on your existing code. This approach helps identify flaws, suggest optimizations, and improve overall code quality.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Iterate with Feedback and Experiment
&lt;/h3&gt;

&lt;p&gt;Treat LLM interactions as iterative conversations. If the initial response isn’t perfect, provide feedback and refine your prompts to get closer to your desired outcome. LLMs retain context within a conversation, making it easier to tweak results over multiple exchanges. Beyond refinement, adopt a curious mindset—experiment with complex tasks like refactoring entire libraries or analyzing intricate codebases. Even if some experiments fail, exploring the LLM’s capabilities can uncover new possibilities for your workflow.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Prioritize Testing and Learning
&lt;/h3&gt;

&lt;p&gt;While LLMs can generate code quickly, always review and test their output rigorously to ensure it functions correctly and integrates well with your codebase. Avoid the temptation to copy-paste without scrutiny. LLMs also serve as powerful learning tools, suggesting designs, libraries, or approaches you might not have considered. Use follow-up questions to explore pros and cons or request example code. However, as the context expert, you must critically evaluate all suggestions to ensure they align with your project’s needs. Your judgment remains essential in driving successful outcomes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Integrating LLMs into software development can transform your workflow, but it requires thoughtful prompting and active oversight. By being specific, assigning roles, iterating with feedback, experimenting boldly, and prioritizing testing and learning, you can harness LLMs effectively. Ultimately, you remain in the driver’s seat, ensuring the code meets your project’s unique requirements. With these best practices, you’re equipped to code smarter and more efficiently alongside LLMs.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>softwaredevelopment</category>
      <category>llm</category>
    </item>
    <item>
      <title>What are those curve values in staggered menu animation?</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Thu, 06 Jul 2023 02:45:11 +0000</pubDate>
      <link>https://dev.to/kalokli8/what-are-those-curve-values-in-staggered-menu-animation-55m5</link>
      <guid>https://dev.to/kalokli8/what-are-those-curve-values-in-staggered-menu-animation-55m5</guid>
      <description>&lt;p&gt;&lt;a href="https://docs.flutter.dev/cookbook/effects/staggered-menu-animation"&gt;https://docs.flutter.dev/cookbook/effects/staggered-menu-animation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above official doc, it does not explain this code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final animationPercent = Curves.easeOut.transform(_itemSlideIntervals[i].transform(
_staggeredController.value),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;Widget&amp;gt; _buildListItems() {
  final listItems = &amp;lt;Widget&amp;gt;[];
  for (var i = 0; i &amp;lt; _menuTitles.length; ++i) {
    listItems.add(
      AnimatedBuilder(
        animation: _staggeredController,
        builder: (context, child) {
          final animationPercent = Curves.easeOut.transform(
            _itemSlideIntervals[i].transform(_staggeredController.value),
          );
          final opacity = animationPercent;
          final slideDistance = (1.0 - animationPercent) * 150;

          return Opacity(
            opacity: opacity,
            child: Transform.translate(
              offset: Offset(slideDistance, 0),
              child: child,
            ),
          );
        },
        child: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 36, vertical: 16),
          child: Text(
            _menuTitles[i],
            textAlign: TextAlign.left,
            style: const TextStyle(
              fontSize: 24,
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
      ),
    );
  }
  return listItems;
}

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

&lt;/div&gt;



&lt;p&gt;After some studying, these three values are all between 0.0 to 1.0.&lt;/p&gt;

&lt;p&gt;_staggeredController.value represents the current progress of the overall animation,&lt;/p&gt;

&lt;p&gt;_itemSlideIntervals[i].transform(_staggeredController.value) is used to control the timing of the animation for each menu item, and &lt;/p&gt;

&lt;p&gt;Curves.easeOut.transform(_itemSlideIntervals[i].transform(_staggeredController.value)) applies an easing curve to the animation.&lt;/p&gt;

</description>
      <category>flutter</category>
    </item>
    <item>
      <title>Why the SingleChildScrollView widget load all data at once(does not lazy loading)?</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Wed, 28 Jun 2023 09:45:53 +0000</pubDate>
      <link>https://dev.to/kalokli8/why-the-singlechildscrollview-widget-load-all-data-at-oncedoes-not-lazy-loading-78f</link>
      <guid>https://dev.to/kalokli8/why-the-singlechildscrollview-widget-load-all-data-at-oncedoes-not-lazy-loading-78f</guid>
      <description>&lt;p&gt;The fundamental difference between SingleChildScrollView and CustomScrollView lies in their design and intended use-cases.&lt;/p&gt;

&lt;p&gt;SingleChildScrollView is a simple widget that combines a scrollable area with a single child. It's intended to be used where there is a need to make a single child scrollable. This child widget is typically a Column, Row, or Flex that contains a large number of items. All the children of these widgets are loaded at once, which might lead to performance issues if the list is very long. In other words, SingleChildScrollView does not support lazy loading.&lt;/p&gt;

&lt;p&gt;On the other hand, CustomScrollView is a more complex widget that can contain multiple children, each of which could be a scrollable area (a Sliver). Slivers are a lower-level primitive that describe part of the layout and can change their behavior based on the scroll position. This makes CustomScrollView more flexible and capable of handling complex layouts.&lt;/p&gt;

&lt;p&gt;Some of the slivers like SliverList or SliverGrid support builder delegates (SliverChildBuilderDelegate), which create children on-demand, as they scroll onto the screen. This is the mechanism that enables lazy loading in CustomScrollView.&lt;/p&gt;

&lt;p&gt;In essence, if you need to display a potentially large list of widgets and want it to be efficiently loaded, it's better to use CustomScrollView with slivers. If you just need to make a relatively small number of widgets scrollable, SingleChildScrollView would be a simpler choice.&lt;/p&gt;

</description>
      <category>flutter</category>
    </item>
    <item>
      <title>Dart cascade notation (..) and usage in list</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Tue, 17 Jan 2023 04:05:13 +0000</pubDate>
      <link>https://dev.to/kalokli8/dart-cascade-notation-and-usage-in-list-2ana</link>
      <guid>https://dev.to/kalokli8/dart-cascade-notation-and-usage-in-list-2ana</guid>
      <description>&lt;p&gt;A bit introduction: according to dart.dev: &lt;/p&gt;

&lt;p&gt;Cascades (.., ?..) allow you to make a sequence of operations on the same object. In addition to accessing instance members, you can also call instance methods on that same object. This often saves you the step of creating a temporary variable and allows you to write more fluid code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var paint = Paint()
  ..color = Colors.black
  ..strokeCap = StrokeCap.round
  ..strokeWidth = 5.0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The constructor, Paint(), returns a Paint object. The code that follows the cascade notation operates on this object, ignoring any values that might be returned.&lt;/p&gt;

&lt;p&gt;The previous example is equivalent to this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var paint = Paint();
paint.color = Colors.black;
paint.strokeCap = StrokeCap.round;
paint.strokeWidth = 5.0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also not assign the value and just run some functions.&lt;br&gt;
Let's play around and see these examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Cat {
  String sound() =&amp;gt; 'hi';
  String sound2() =&amp;gt; 'hi2';
}

void main() {
  // Create a Cat instance
  final cat = Cat();

  print(cat.sound()); // 'hi'
  print(cat..sound()..sound2()); // Instance of 'Cat'


  print([]..add(1)); // [1]

  print([].add(1));
  // Error: This expression has type 'void' and can't be used.
  // You can't print void value.

  [].add(1); 
  // The array is [1].The add method returns 
  // void and the value is not assigned to any variable.



  List&amp;lt;int&amp;gt; num = [1];
  num.add(2); 
  num.add(3); 
  print(num);
  // [1,2,3]

  // It is equivalent:
  List&amp;lt;int&amp;gt; num2 = [1]..add(2)..add(3);
  print(num2);
  // [1,2,3]

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

&lt;/div&gt;



&lt;p&gt;Finally, I find this link useful when encounter errors of &lt;br&gt;
'Cannot add to an unmodifiable list' or 'The default value of an optional parameter must be constant': &lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/66550202/how-to-add-to-an-existing-list-got-unsupported-operation-cannot-add-to-an-unm"&gt;https://stackoverflow.com/questions/66550202/how-to-add-to-an-existing-list-got-unsupported-operation-cannot-add-to-an-unm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basically it means the 'const' keyword makes the list unmodifiable. You can use spread operator(...) or List.from() to make a new array to solve this problem.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chat.messages = [...chat.messages, message];&lt;/code&gt;&lt;br&gt;
&lt;code&gt;chat.messages = List.from(chat.messages)..add(message)&lt;/code&gt;;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>SVG intro</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Mon, 18 Jul 2022 10:28:31 +0000</pubDate>
      <link>https://dev.to/kalokli8/svg-intro-4o4</link>
      <guid>https://dev.to/kalokli8/svg-intro-4o4</guid>
      <description>&lt;h2&gt;
  
  
  What is SVG?
&lt;/h2&gt;

&lt;p&gt;SVG is an image format for vector graphics. It literally means Scalable Vector Graphics&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why SVG does not lose clarity? (It scales to any size while maintaining quality)
&lt;/h2&gt;

&lt;p&gt;An SVG image's data is stored as XML instead of pixels, and consists of components that can be scaled to any level without losing source quality.&lt;/p&gt;


&lt;h2&gt;
  
  
  Differences Between SVG and Canvas
&lt;/h2&gt;

&lt;p&gt;SVG is a language for describing 2D graphics in XML.&lt;/p&gt;

&lt;p&gt;Canvas draws 2D graphics, on the fly (with a JavaScript).&lt;/p&gt;

&lt;p&gt;SVG is XML based, which means that every element is available within the SVG DOM. You can attach JavaScript event handlers for an element.&lt;/p&gt;

&lt;p&gt;In SVG, each drawn shape is remembered as an object. If attributes of an SVG object are changed, the browser can automatically re-render the shape.&lt;/p&gt;

&lt;p&gt;Canvas is rendered pixel by pixel. In canvas, once the graphic is drawn, it is forgotten by the browser. If its position should be changed, the entire scene needs to be redrawn, including any objects that might have been covered by the graphic&lt;/p&gt;

&lt;p&gt;Example Code of a triangle:&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;svg height="210" width="400"&amp;gt;
  &amp;lt;path d="M150 0 L75 200 L225 200 Z" /&amp;gt;
&amp;lt;/svg&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
M = moveto&lt;br&gt;
L = lineto&lt;br&gt;
Z = closepath&lt;/p&gt;

&lt;p&gt;Capital letters means absolutely positioned, lower cases means relatively positioned.&lt;/p&gt;

&lt;p&gt;Source: W3 school&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to add dark mode (Color theme)</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Tue, 28 Jun 2022 06:46:10 +0000</pubDate>
      <link>https://dev.to/kalokli8/how-to-add-dark-mode-color-theme-2k0p</link>
      <guid>https://dev.to/kalokli8/how-to-add-dark-mode-color-theme-2k0p</guid>
      <description>&lt;h2&gt;
  
  
  Operating System
&lt;/h2&gt;

&lt;p&gt;In Mac, you can choose your color theme:&lt;br&gt;
System Preferences --&amp;gt; General --&amp;gt; Appearance&lt;/p&gt;
&lt;h3&gt;
  
  
  The prefers-color-scheme CSS media feature is used to detect if the user has requested a light or dark color theme.
&lt;/h3&gt;

&lt;p&gt;Syntax example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (prefers-color-scheme: dark) {
  .day.dark-scheme   { background:  #333; color: white; }
  .night.dark-scheme { background: black; color:  #ddd; }
}

@media (prefers-color-scheme: light) {
  .day.light-scheme   { background: white; color:  #555; }
  .night.light-scheme { background:  #eee; color: black; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result: &lt;a href="https://yari-demos.prod.mdn.mozit.cloud/en-US/docs/Web/CSS/@media/prefers-color-scheme/_sample_.examples.html"&gt;https://yari-demos.prod.mdn.mozit.cloud/en-US/docs/Web/CSS/@media/prefers-color-scheme/_sample_.examples.html&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Change to dark mode manually(such as switch toggle) using ‘class’ strategy in Tailwindcss
&lt;/h3&gt;

&lt;p&gt;First, add "dark:" before the class you want in dark mode&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;div class="bg-white dark:bg-black"&amp;gt;
    &amp;lt;!-- ... --&amp;gt;
  &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, in tailwind.config.js, add&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  darkMode: 'class',
  // ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resources: &lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/docs/dark-mode"&gt;https://tailwindcss.com/docs/dark-mode&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CSS units</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Sat, 21 May 2022 02:09:02 +0000</pubDate>
      <link>https://dev.to/kalokli8/css-units-2052</link>
      <guid>https://dev.to/kalokli8/css-units-2052</guid>
      <description>&lt;p&gt;font-size: rem&lt;br&gt;
width: % in combination with a max-width, ch&lt;br&gt;
height: question urself "do i rly need to set height" if yes -&amp;gt; use a min-height&lt;br&gt;
padding/margin: rem or em, em for padding of buttons&lt;br&gt;
media queries: em&lt;/p&gt;

&lt;p&gt;px only for little things like shadows, borders etc.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to reverse a link list.</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Mon, 09 May 2022 05:33:47 +0000</pubDate>
      <link>https://dev.to/kalokli8/how-to-reverse-a-link-list-3e90</link>
      <guid>https://dev.to/kalokli8/how-to-reverse-a-link-list-3e90</guid>
      <description>&lt;p&gt;reverse() {&lt;br&gt;
    let current = this.head;&lt;br&gt;
    let next = null;&lt;br&gt;
    let previous = null;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(current !== null) {
  next = current.next;
  current.next = previous;
  previous = current;
  current = next;
}

this.head = previous;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;visualization video: &lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=D7y_hoT_YZI&amp;amp;ab_channel=GeeksforGeeks"&gt;https://www.youtube.com/watch?v=D7y_hoT_YZI&amp;amp;ab_channel=GeeksforGeeks&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Grid Responsive</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Sat, 16 Apr 2022 09:38:19 +0000</pubDate>
      <link>https://dev.to/kalokli8/grid-responsive-3j9e</link>
      <guid>https://dev.to/kalokli8/grid-responsive-3j9e</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-gap: 10px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>XOR Python</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Mon, 11 Apr 2022 13:46:57 +0000</pubDate>
      <link>https://dev.to/kalokli8/xor-python-4h2</link>
      <guid>https://dev.to/kalokli8/xor-python-4h2</guid>
      <description>&lt;p&gt;XOR Operator in Python is also known as “exclusive or”. It compares two binary numbers bitwise if two bits are identical XOR outputs as 0 and when two bits are different then XOR outputs as 1.&lt;/p&gt;

&lt;p&gt;Bitwise operators in Python are also called binary operators.  In calculation, the integers are first converted into binary, and later the operations are performed bit by bit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a=  5  #0101
b = 3  #0011

result  = (a ^ b) #0110

print(result)

# Output
# 6 (0110)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(True ^ True) // False
print(True ^ False) // True
print(False ^ True) // True
print(False ^ False) //False
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;find non-duplicate in [7,3,3,4,4,5,5]&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def singleNumber(self, nums: List[int]) -&amp;gt; int:
    n=len(nums)
    r=nums[0]
    for i in range(1,n):
        r = r ^ nums[i] 

    return r

r = 7 ^ 3 ^ 5 ^ 4 ^ 5 ^ 3 ^ 4

Since XOR is associative and commutative, above
expression can be written as:
r = 7 ^ (3 ^ 3) ^ (4 ^ 4) ^ (5 ^ 5)
= 7 ^ 0 ^ 0 ^ 0
= 7 ^ 0
= 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;credit: &lt;a href="https://itsmycode.com/xor-in-python/"&gt;https://itsmycode.com/xor-in-python/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to write shorter code using python in Leetcode</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Sun, 10 Apr 2022 12:55:28 +0000</pubDate>
      <link>https://dev.to/kalokli8/how-to-write-shorter-code-using-python-in-leetcode-3keo</link>
      <guid>https://dev.to/kalokli8/how-to-write-shorter-code-using-python-in-leetcode-3keo</guid>
      <description>&lt;h1&gt;
  
  
  How to get index in a for loop in Python?
&lt;/h1&gt;

&lt;p&gt;Naive: use a variable&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;count = 0
for i in range(5):
//  some code using count index
    count += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Smart: use enumerate function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for idx, val in enumerate(ints):
    print(idx, val)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  How to get unique key from value in dictionary?
&lt;/h1&gt;

&lt;p&gt;// my_dict.items() look like this:&lt;br&gt;
// [("a", 1), ("b", 2), ("c", 3)]&lt;/p&gt;

&lt;p&gt;my_dict ={"a": 1, "b": 2, "c": 3}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def get_key(val):
    for key, value in my_dict.items():
        if val == value:
            return key

    return "no match"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;my_dict = {"a": 1, "b": 2, "c": 3}&lt;br&gt;
print(get_key(1))&lt;br&gt;
print(get_key(2))&lt;/p&gt;
&lt;h1&gt;
  
  
  List Comprehension
&lt;/h1&gt;

&lt;p&gt;Syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;newlist = [expression for item in iterable if condition == True]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;fruits = ["apple", "banana", "cherry", "kiwi", "mango"]&lt;br&gt;
newlist = [x for x in fruits if x != "apple"]&lt;br&gt;
print(newlist)&lt;br&gt;
&lt;code&gt;output: ['banana', 'cherry', 'kiwi', 'mango']&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is drwx when using ls -la</title>
      <dc:creator>kalokli8</dc:creator>
      <pubDate>Sun, 10 Apr 2022 03:25:23 +0000</pubDate>
      <link>https://dev.to/kalokli8/what-is-drwx-when-using-ls-la-4jmf</link>
      <guid>https://dev.to/kalokli8/what-is-drwx-when-using-ls-la-4jmf</guid>
      <description>&lt;p&gt;Display the content of a folder including hidden files and additional information using this command:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls -la ~/.ssh&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Note: l stands for long, it will display additional information about the files and directories&lt;/li&gt;
&lt;li&gt;Note: a stands for all, it will display hidden files as well&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;~/.ssh: find .ssh folder in root directory&lt;/p&gt;

&lt;p&gt;The terminal shows:&lt;br&gt;
&lt;code&gt;drwx--xr-x 1 user staff 3389 10 Apr 11:11 id_rsa&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It is about file permissions on unix/linux/whatever on the net. &lt;br&gt;
The first character tells you if it is a directory (marked as ‚d‘), then you continue in groups of three for read (‚r‘), write (‚w’) and execute (‚x’) permissions for the owning user, group and everyone else.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
