<?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: Poopcoder</title>
    <description>The latest articles on DEV Community by Poopcoder (@poopcoder).</description>
    <link>https://dev.to/poopcoder</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%2F524044%2F415394ff-bf80-445d-a795-5cea68880ee0.png</url>
      <title>DEV Community: Poopcoder</title>
      <link>https://dev.to/poopcoder</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/poopcoder"/>
    <language>en</language>
    <item>
      <title>Remove unused npm modules from package.json</title>
      <dc:creator>Poopcoder</dc:creator>
      <pubDate>Wed, 24 Feb 2021 15:50:55 +0000</pubDate>
      <link>https://dev.to/poopcoder/remove-unused-npm-modules-from-package-json-2e7i</link>
      <guid>https://dev.to/poopcoder/remove-unused-npm-modules-from-package-json-2e7i</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/depcheck/depcheck"&gt;Depcheck&lt;/a&gt; is a tool for analyzing the dependencies in a project to see: how each dependency is used, which dependencies are useless, and which dependencies are unused from package.json. To identify the unused package, just run &lt;em&gt;npx depcheck&lt;/em&gt; in the project root directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; npx depcheck


npx: installed 146 in 88.761s
Unused dependencies
* express-validator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step is to &lt;a href="https://poopcode.com/how-to-uninstall-npm-modules-in-node-js/"&gt;uninstall the npm packages&lt;/a&gt; using &lt;em&gt;npm uninstall&lt;/em&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm uninstall express-validator
npm WARN retina-backend@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

removed 2 packages and audited 626 packages in 12.337s

24 packages are looking for funding
  run `npm fund` for details

found 24150 vulnerabilities (24147 low, 3 high)
  run `npm audit fix` to fix them, or `npm audit` for details
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The post &lt;a href="https://poopcode.com/remove-unused-npm-modules-from-package-json/"&gt;Remove unused npm modules from package.json&lt;/a&gt; appeared first on &lt;a href="https://poopcode.com"&gt;Poopcode&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>node</category>
      <category>depchecknpm</category>
      <category>npxdepcheck</category>
      <category>removeunusednpmpackagejson</category>
    </item>
    <item>
      <title>How to create copies of a string in JavaScript?</title>
      <dc:creator>Poopcoder</dc:creator>
      <pubDate>Sat, 20 Feb 2021 12:56:38 +0000</pubDate>
      <link>https://dev.to/poopcoder/how-to-create-copies-of-a-string-in-javascript-42d7</link>
      <guid>https://dev.to/poopcoder/how-to-create-copies-of-a-string-in-javascript-42d7</guid>
      <description>&lt;p&gt;To create copies of a string in &lt;a href="https://poopcode.com/category/javascript/"&gt;JavaScript&lt;/a&gt;, we can use String.prototype.repeat() method. It takes a number as an argument and repeats the &lt;a href="https://poopcode.com/string-contains-whitespace-javascript/"&gt;string&lt;/a&gt; n times and returns it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let str = "poopcode";

console.log(str.repeat(2)); //poopcodepoopcode

console.log(str.repeat(5)); //poopcodepoopcodepoopcodepoopcodepoopcode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>solutions</category>
      <category>repeatstringntimesja</category>
      <category>stringclonejavascrip</category>
      <category>stringrepeatjavascri</category>
    </item>
    <item>
      <title>What are the possible ways to create objects in JavaScript?</title>
      <dc:creator>Poopcoder</dc:creator>
      <pubDate>Thu, 18 Feb 2021 12:57:20 +0000</pubDate>
      <link>https://dev.to/poopcoder/what-are-the-possible-ways-to-create-objects-in-javascript-2nmo</link>
      <guid>https://dev.to/poopcoder/what-are-the-possible-ways-to-create-objects-in-javascript-2nmo</guid>
      <description>&lt;p&gt;There are many ways to create objects in JavaScript as described below. &lt;/p&gt;

&lt;h1&gt;
  
  
  Object constructor
&lt;/h1&gt;

&lt;p&gt;The simplest way to create an empty object is using the Object constructor. This approach is not recommended anymore.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var object = new Object();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Object’s create method
&lt;/h1&gt;

&lt;p&gt;The create method of Object creates a new object by passing the prototype object as a parameter to the create() method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var object = Object.create(null);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Object literal syntax
&lt;/h1&gt;

&lt;p&gt;The object literal syntax is equivalent to create method when it passes null as parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var object = {};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Function constructor
&lt;/h1&gt;

&lt;p&gt;Create any function and apply the new operator to create object instances.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Employee(name){
   var object = {};
   object.name=name;
   object.salary=1000;
   return object;
}
var object = new Person("John");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Object literal syntax
&lt;/h1&gt;

&lt;p&gt;The object literal syntax is equivalent to create method when it passes null as parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var object = {};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Function constructor + prototype
&lt;/h1&gt;

&lt;p&gt;This is similar to function constructor but it uses prototype for their properties and methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myObj(){};
myObj.prototype.name = "hello";
var k = new myObj();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  ES6 class syntax
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class myObject  {
  constructor(name) {
    this.name = name;
  }
}
var e = new myObject("hello");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Singleton pattern
&lt;/h1&gt;

&lt;p&gt;A Singleton is an object which can only be instantiated one time. Repeated calls to its constructor return the same instance and this way one can ensure that they don’t accidentally create multiple instances.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var object = new function(){
   this.name = "Anand";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>createobjectjavascri</category>
      <category>es6classsyntax</category>
      <category>es6objectcreationjav</category>
    </item>
    <item>
      <title>How to check if a list is empty in Python?</title>
      <dc:creator>Poopcoder</dc:creator>
      <pubDate>Thu, 17 Dec 2020 11:55:38 +0000</pubDate>
      <link>https://dev.to/poopcoder/how-to-check-if-a-list-is-empty-in-python-25p</link>
      <guid>https://dev.to/poopcoder/how-to-check-if-a-list-is-empty-in-python-25p</guid>
      <description>&lt;p&gt;In this tutorial we discuss the various ways of checking if a list is empty in Python. &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;len&lt;/strong&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lst = [1,2,3]

if len(lst) == 0:
    print 'List Empty'
else:
    print 'List not empty'

#List not empty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;bool&lt;/strong&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lst = [1,2,3]

if not bool(list):
    print 'List Empty'
else:
    print 'List not empty'

#List not empty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;equal&lt;/strong&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lst = [1,2,3]

if lst == []:
    print 'List Empty'
else:
    print 'List not empty'

#List not empty
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The post &lt;a href="https://poopcode.com/how-to-check-if-a-list-is-empty-in-python/"&gt;How to check if a list is empty in Python?&lt;/a&gt; appeared first on &lt;a href="https://poopcode.com"&gt;Poopcode&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
    </item>
    <item>
      <title>How to attach to an existing tmux session?</title>
      <dc:creator>Poopcoder</dc:creator>
      <pubDate>Thu, 17 Dec 2020 04:45:15 +0000</pubDate>
      <link>https://dev.to/poopcoder/how-to-attach-to-an-existing-tmux-session-1neg</link>
      <guid>https://dev.to/poopcoder/how-to-attach-to-an-existing-tmux-session-1neg</guid>
      <description>&lt;p&gt;To get the list of existing tmux session use &lt;em&gt;tmux ls&lt;/em&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; tmux ls
0: 1 windows (created Wed Dec 16 16:45:19 2020)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here there is one session that already exists. To attach to this particular session ‘0’ we can use the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; tmux attach-session -t 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open the existing tmux session.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>tmux</category>
    </item>
    <item>
      <title>Convert a dictionary to a list of tuples in Python</title>
      <dc:creator>Poopcoder</dc:creator>
      <pubDate>Wed, 16 Dec 2020 05:24:18 +0000</pubDate>
      <link>https://dev.to/poopcoder/convert-a-dictionary-to-a-list-of-tuples-in-python-3l4c</link>
      <guid>https://dev.to/poopcoder/convert-a-dictionary-to-a-list-of-tuples-in-python-3l4c</guid>
      <description>&lt;p&gt;To convert a dictionary to a list of tuples you can pass the dictionary items into list constructor and it would return a list of tuples.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dictionary = {'name': 'Anand', 'age': 30, 'sex': 'Male'}
print(list(dictionary.items()))


#[('age', 30), ('name', 'Anand'), ('sex', 'Male')]

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

&lt;/div&gt;



</description>
      <category>snippets</category>
      <category>python</category>
    </item>
  </channel>
</rss>
