<?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>Forem: darker</title>
    <description>The latest articles on Forem by darker (@sanixdarker).</description>
    <link>https://forem.com/sanixdarker</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%2F116967%2Fa255eded-99d2-4ae3-b3e2-29c611c2e164.jpg</url>
      <title>Forem: darker</title>
      <link>https://forem.com/sanixdarker</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sanixdarker"/>
    <language>en</language>
    <item>
      <title>How to execute any command from anywhere to anywhere in your laptop !</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sun, 18 Dec 2022 12:13:56 +0000</pubDate>
      <link>https://forem.com/sanixdarker/how-to-execute-any-command-from-anywhere-to-anywhere-in-your-laptop--1egk</link>
      <guid>https://forem.com/sanixdarker/how-to-execute-any-command-from-anywhere-to-anywhere-in-your-laptop--1egk</guid>
      <description>&lt;p&gt;Sometimes i got in situations where i want to execute a specific command or multiple commands inside a given directory without moving there as quickly as i can !&lt;br&gt;
This may sound obvious to just jump there, do the stuff and come back but as a lazy guy, i like doing that as quickly as possible and hit enter once !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxpojlupfhlk96l544mc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxpojlupfhlk96l544mc.png" alt="target" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in this tip, you will need &lt;a href="https://github.com/ajeetdsouza/zoxide" rel="noopener noreferrer"&gt;zoxide&lt;/a&gt;, a nice tool that cache all your paths by their finals dirname, that mean wherever you are in your linux system &lt;code&gt;~/zig/zag/toum/yyyy&lt;/code&gt;, you just have to type &lt;em&gt;cd xxxx&lt;/em&gt; (which is here &lt;code&gt;~/boum/bam/xxx&lt;/code&gt;), to go there !&lt;/p&gt;

&lt;p&gt;So this is my tip:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;go to the target dir (&lt;code&gt;$1&lt;/code&gt; as the given dir)&lt;/li&gt;
&lt;li&gt;execute the command (&lt;code&gt;{$@:2}&lt;/code&gt; as all strings after the dir)&lt;/li&gt;
&lt;li&gt;get back from where i was (&lt;code&gt;cd -&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie9fgl7nm3okmqygtkpf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie9fgl7nm3okmqygtkpf.jpg" alt="Image" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then add it inside your &lt;code&gt;~/.bash_aliases&lt;/code&gt; and you're good to go !&lt;/p&gt;

&lt;p&gt;You can copy the source code from &lt;a href="https://gist.github.com/Sanix-Darker/27a0cb536b9c2ec7f29f93c70b942785" rel="noopener noreferrer"&gt;here&lt;/a&gt; !&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>unix</category>
      <category>terminal</category>
    </item>
    <item>
      <title>How to list commits from the current branch.</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sun, 28 Aug 2022 13:18:37 +0000</pubDate>
      <link>https://forem.com/sanixdarker/how-to-list-commits-from-the-current-branch-3b2n</link>
      <guid>https://forem.com/sanixdarker/how-to-list-commits-from-the-current-branch-3b2n</guid>
      <description>&lt;p&gt;Let's say, you're on your terminal and you want to have the list of commits from your current branch !&lt;/p&gt;

&lt;p&gt;There is some tricks to do that, the faster one is just to git log and scroll !&lt;br&gt;
But i found useful to made a simple alias to do so !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sfcMMO62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t75742p21orp6clz9kd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sfcMMO62--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t75742p21orp6clz9kd4.png" alt="First" width="880" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, this is quite simple, it's a combination of 2 main commands i set up in my &lt;code&gt;~/.gitconfig&lt;/code&gt; as an alias :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[alias]&lt;/span&gt;
    &lt;span class="err"&gt;;&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;list&lt;/span&gt; &lt;span class="err"&gt;commits&lt;/span&gt; &lt;span class="err"&gt;from&lt;/span&gt; &lt;span class="err"&gt;the&lt;/span&gt; &lt;span class="err"&gt;current&lt;/span&gt; &lt;span class="err"&gt;branch&lt;/span&gt;
    &lt;span class="py"&gt;commit-list&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="err"&gt;!git&lt;/span&gt; &lt;span class="err"&gt;log&lt;/span&gt; &lt;span class="err"&gt;--no-merges&lt;/span&gt; &lt;span class="err"&gt;--oneline&lt;/span&gt; &lt;span class="err"&gt;--decorate&lt;/span&gt; &lt;span class="err"&gt;master..$(git&lt;/span&gt; &lt;span class="err"&gt;branch&lt;/span&gt; &lt;span class="err"&gt;--show-current)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  HOW
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;First, i need to get the branch where i am right now, and to do that, i use &lt;code&gt;git branch --show-current&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Second, am going to compare with &lt;code&gt;git log&lt;/code&gt;, the difference commits from my branch to the master branch, because i don't want merges, nor too much details, i added two flags, &lt;code&gt;--no-merges&lt;/code&gt; and &lt;code&gt;--oneline&lt;/code&gt; + a simple &lt;code&gt;--decorate&lt;/code&gt;. &lt;code&gt;git log --no-merges --oneline --decorate&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  DEMO
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HmNOiIr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyv4xoqehryc6k0mnxg3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HmNOiIr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oyv4xoqehryc6k0mnxg3.gif" alt="Demo" width="880" height="593"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PS:&lt;/strong&gt; Don't worry about the "passphrase" on the demo, i added a lot of security checks for any git command on my local machine, i may do a future post about that soon !&lt;/p&gt;

&lt;p&gt;EDIT : From Christophe Colombier, you can do the same thing with a native command, such as : &lt;code&gt;git cherry -v origin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading, feel free to like and/or subscribe for more 🐼.&lt;/p&gt;

</description>
      <category>git</category>
      <category>bash</category>
      <category>code</category>
      <category>log</category>
    </item>
    <item>
      <title>How to git resolve conflicts quickly from two commands lines.</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sat, 20 Aug 2022 11:51:27 +0000</pubDate>
      <link>https://forem.com/sanixdarker/how-to-git-resolve-conflicts-quickly-from-one-command-line-3ge1</link>
      <guid>https://forem.com/sanixdarker/how-to-git-resolve-conflicts-quickly-from-one-command-line-3ge1</guid>
      <description>&lt;p&gt;When rebasing/merging, you may face sometimes conflicts, and if you're like me... "LAZY", you just want to get all new changes from the main branch or keep all your current changes as fast as possible depending on the file !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HXNA9Ke9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y09blhusbpfiqzlv1piw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HXNA9Ke9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y09blhusbpfiqzlv1piw.png" alt="Example" width="880" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, for conflicts on some file, you may need to get incoming changes or keep your current changes ! I made two alias for that, &lt;code&gt;git add-their&lt;/code&gt; and &lt;code&gt;git add-our&lt;/code&gt; !&lt;/p&gt;

&lt;p&gt;Under the hood, what it's done is quite simple, in your &lt;code&gt;~/.gitconfig&lt;/code&gt; section, you just have to add those lines :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="nn"&gt;[alias]&lt;/span&gt;
      &lt;span class="py"&gt;add-their&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="err"&gt;!git&lt;/span&gt; &lt;span class="err"&gt;checkout&lt;/span&gt; &lt;span class="err"&gt;--ours&lt;/span&gt; &lt;span class="err"&gt;$@&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;git&lt;/span&gt; &lt;span class="err"&gt;add&lt;/span&gt; &lt;span class="err"&gt;$@&lt;/span&gt;
      &lt;span class="py"&gt;add-our&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="err"&gt;!git&lt;/span&gt; &lt;span class="err"&gt;checkout&lt;/span&gt; &lt;span class="err"&gt;--theirs&lt;/span&gt; &lt;span class="err"&gt;$@&lt;/span&gt; &lt;span class="err"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="err"&gt;git&lt;/span&gt; &lt;span class="err"&gt;add&lt;/span&gt; &lt;span class="err"&gt;$@&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, how this work, it's mostly two main commands, a checkout command and an add command, let's focus on keywords (theirs and ours) and how they are reverted !&lt;/p&gt;

&lt;p&gt;In a context of rebasing, if you're willing to set current changes with these aliases, you should do &lt;code&gt;git add-our&lt;/code&gt; and &lt;code&gt;git add-their&lt;/code&gt; for incoming ones, that logic is inverted when you're dealing with merge conflicts. this is a &lt;a href="https://howchoo.com/git/git-merge-conflicts-rebase-ours-theirs"&gt;good article&lt;/a&gt; that go deeply on explanations !&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IMPORTANT NOTE&lt;/strong&gt; : these aliases are only for the one knowing what they are doing, cuz on a complicated conflicts, there is some stuff you will want to keep on both side !&lt;/p&gt;

</description>
      <category>git</category>
      <category>bash</category>
      <category>alias</category>
      <category>conflicts</category>
    </item>
    <item>
      <title>Bash and exclamation marks !!!!</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Thu, 18 Aug 2022 14:40:33 +0000</pubDate>
      <link>https://forem.com/sanixdarker/bash-and-exclamation-marks--3ii8</link>
      <guid>https://forem.com/sanixdarker/bash-and-exclamation-marks--3ii8</guid>
      <description>&lt;p&gt;In case you didn't know, exclamation marks play an important role in the bash workflow, especially for your command history!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgh260avy87m5rzw4yhrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgh260avy87m5rzw4yhrh.png" alt="Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ok... let me explain this weird thing, actually it's simple : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first part of the command will take the first command item from the second most recent command you   wrote, then concatenate to "add" and the second item of the most recent command, &lt;code&gt;git add second_folder&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For the second part, it's a substitution command of "status" by "checkout" for the second command that i wrote, in reverse order on my bash history; it will take as arguments, those that i gave to my second command in the same order.&lt;br&gt;
That said, the output of this command will be:&lt;br&gt;
&lt;code&gt;git checkout second_folder&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pretty NEAT right !?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So let's talk about it, the &lt;code&gt;!&lt;/code&gt; invokes history expansion, a feature that originally appeared in the C shell, back in the days before you could count on terminals to have arrow keys. It's especially useful if you add the current command number to the prompt &lt;code&gt;(PS1="\!$ ")&lt;/code&gt; so you can quickly look at your screen to get numbers for past commands.&lt;/p&gt;

&lt;p&gt;So, am not going to go deep inside possibilities here but just give some cool cheat-sheets from exclamations marks when you're on your terminal !&lt;/p&gt;

&lt;p&gt;This is a pretty short list of the cool ones :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;!!&lt;/code&gt; run the latest command,&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="c"&gt;# Ex :&lt;/span&gt;
 &lt;span class="nv"&gt;$ &lt;/span&gt;apt-get update
 &lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;!-3&lt;/code&gt; run the third command in the reverse order from my bash history; this is also available for positive values such as the first command, from your &lt;code&gt;~/.bash_history&lt;/code&gt; -&amp;gt; &lt;code&gt;!1&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;!*&lt;/code&gt; get arguments passed to the most recent command ran,&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="c"&gt;# Ex :&lt;/span&gt;
 &lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;filex, test4, example
 &lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;777 &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;!ls&lt;/code&gt; to run a command from your history starting with &lt;code&gt;ls&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these 4 items, you can basically play/mix around with your bash history and get great stuffs like the one up there with a substitution string.&lt;/p&gt;

&lt;p&gt;Thanks for reading, feel free to like and/or subscribe for more 🐼.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>cheatsheet</category>
      <category>terminal</category>
      <category>shortcut</category>
    </item>
    <item>
      <title>How to count lines of your code from your SHELL.</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Mon, 15 Aug 2022 21:42:30 +0000</pubDate>
      <link>https://forem.com/sanixdarker/how-to-count-lines-of-your-code-from-your-shell-3akp</link>
      <guid>https://forem.com/sanixdarker/how-to-count-lines-of-your-code-from-your-shell-3akp</guid>
      <description>&lt;p&gt;So, this one is quite simple, let say, you want to count the lines of code you have inside a project, from a file or a whole directory, how are you going to do it ?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o49IfFBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk4jyi0eqv5f15wvlcjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o49IfFBt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk4jyi0eqv5f15wvlcjv.png" alt="Demo" width="880" height="645"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  HOW
&lt;/h3&gt;

&lt;p&gt;This is done with a simple bash function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;loc&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-ne&lt;/span&gt; &lt;span class="s2"&gt;"Lines of Code : "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-wholename&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; | xargs &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;find &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-name&lt;/span&gt; &lt;span class="s1"&gt;'*'&lt;/span&gt; &lt;span class="nt"&gt;-type&lt;/span&gt; f | xargs &lt;span class="nb"&gt;cat&lt;/span&gt; | &lt;span class="nb"&gt;wc&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically, it will find files depending on your input and use &lt;code&gt;wc&lt;/code&gt; to count lines of your code.&lt;/p&gt;

&lt;p&gt;You can then add this in your &lt;code&gt;~/.bashrc&lt;/code&gt; and source before use it or save it in separate shell file that you can call and use when you want !&lt;/p&gt;

&lt;p&gt;Thanks for reading, feel free to like and/or subscribe for more 🐼.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>code</category>
      <category>lines</category>
      <category>count</category>
    </item>
    <item>
      <title>How to copy/paste files/directories into non-existent destination path</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sat, 13 Aug 2022 18:24:40 +0000</pubDate>
      <link>https://forem.com/sanixdarker/how-to-copypaste-filesdirectories-into-non-existent-destination-path-338g</link>
      <guid>https://forem.com/sanixdarker/how-to-copypaste-filesdirectories-into-non-existent-destination-path-338g</guid>
      <description>&lt;p&gt;Have you ever tried to copy some file(s) or directory(ies) to a destination that doesn't exist yet ? It's possible with a smart bash function !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XqH3NiX7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0sss3wj3yqs2xeuyiu0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XqH3NiX7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z0sss3wj3yqs2xeuyiu0.jpeg" alt="How doe's it work" width="880" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HOW ?
&lt;/h2&gt;

&lt;p&gt;How to obtain that ?&lt;br&gt;
Using this bash script function :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cpd&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;dirname&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="p"&gt;@&lt;/span&gt;:&lt;span class="p"&gt; -1&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nv"&gt;$@&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;First, we create recursively the destination folder by getting the dir name of the last argument passed to the function.&lt;/li&gt;
&lt;li&gt;And we copy recursively depending on the array of arguments passed to the function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As the final step, You just have to add it in your &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;source ~/.bashrc&lt;/code&gt; and you're good to go !&lt;/p&gt;

&lt;h2&gt;
  
  
  DEMO ?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1ShXbFHX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wi18vln6ol2yxuqa9mp9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1ShXbFHX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wi18vln6ol2yxuqa9mp9.gif" alt="Demo" width="880" height="721"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading, feel free to like and/or subscribe for more 🐼.&lt;/p&gt;

</description>
      <category>copy</category>
      <category>paste</category>
      <category>directory</category>
      <category>path</category>
    </item>
    <item>
      <title>How to clone a sub directory of a git project (not a zip)</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Fri, 12 Aug 2022 19:10:19 +0000</pubDate>
      <link>https://forem.com/sanixdarker/how-to-clone-a-sub-directory-of-a-git-project-not-a-zip-1kk7</link>
      <guid>https://forem.com/sanixdarker/how-to-clone-a-sub-directory-of-a-git-project-not-a-zip-1kk7</guid>
      <description>&lt;p&gt;Have you ever tried to get a folder from a git repository either on github, gitlab or bitbucket ?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm93toqmbg8cgm1me7qg5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm93toqmbg8cgm1me7qg5.png" alt="Final Demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;hop hop hop, am not talking about Downloading a ZIP folder (like DownGit does), but only cloning a sub-directory with the git clone... command !&lt;/p&gt;

&lt;p&gt;I got that question from a friend, and i wrote a small and interesting bash script to do so !&lt;/p&gt;

&lt;p&gt;We're going to do that in 2 steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  WRITE A BASH SCRIPT FUNCTION
&lt;/h2&gt;

&lt;p&gt;We're going to write a function in our &lt;code&gt;.bashrc&lt;/code&gt; that will update our &lt;a href="https://git-scm.com/docs/git-sparse-checkout" rel="noopener noreferrer"&gt;sparse-checkout&lt;/a&gt; like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;_git_clone_sub &lt;span class="o"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;REPO_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-oE&lt;/span&gt; &lt;span class="s1"&gt;'[^/]+$'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    git clone &lt;span class="nt"&gt;--filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;blob:none &lt;span class="nt"&gt;--no-checkout&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt;
    &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="nv"&gt;$REPO_NAME&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    git sparse-checkout &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--no-cone&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;/*"&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;git pull origin &lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        git checkout &lt;span class="nv"&gt;$3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;git fetch origin&lt;span class="p"&gt;;&lt;/span&gt;
        git checkout main
        &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$?&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; 0 &lt;span class="o"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; git checkout master&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script is quite simple, this is what it does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extract the repo name from the link (github.com/author/repo-name).&lt;/li&gt;
&lt;li&gt;Create a git project with the repo name + add the origin from the link.&lt;/li&gt;
&lt;li&gt;Then update the tree configuration of our project.&lt;/li&gt;
&lt;li&gt;As an optional parameter, we have the branch, if it's provide, the script will clone a sub directory from that branch, otherwise, it will clone from master (you can change that with &lt;code&gt;main&lt;/code&gt; if you want).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we can easily clone sub directories like this (after a &lt;code&gt;source ~/.bashrc&lt;/code&gt;) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;_git_clone_sub subDir1 https://github.com/auth/repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or by specifying the branch name :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;_git_clone_sub subDir1 https://github.com/auth/repo dev-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  WRITE A GIT ALIAS
&lt;/h2&gt;

&lt;p&gt;So far so good... but we can do better !&lt;br&gt;
We could call that bash function from git directly by adding an alias in our &lt;code&gt;~/.gitconfig&lt;/code&gt; file like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;[&lt;span class="n"&gt;alias&lt;/span&gt;]
    &lt;span class="n"&gt;clone&lt;/span&gt;-&lt;span class="n"&gt;sub&lt;/span&gt; = !&lt;span class="n"&gt;bash&lt;/span&gt; -&lt;span class="n"&gt;i&lt;/span&gt; -&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="s1"&gt;'_git_clone_sub "$@"'&lt;/span&gt; -&lt;span class="n"&gt;s&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah yeah wait a minute, i know, that one looks weird, but let me explain... it's actually simple !&lt;/p&gt;

&lt;p&gt;First, since we are going to run a bash function, we embrace that with 'bash -c'; then we call our function.&lt;br&gt;
The &lt;code&gt;$@&lt;/code&gt; is to get all arguments got using the &lt;code&gt;-s&lt;/code&gt; flag at the end of the alias.&lt;/p&gt;

&lt;p&gt;That's been said, you can now do :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone-sub subDir1 https://github.com/auth/repo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone-sub subDir1 https://github.com/auth/repo dev-branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  DEMO
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnulatd2q852objx9f7zo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnulatd2q852objx9f7zo.gif" alt="DEMO"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading, feel free to like and/or subscribe for more 🐼.&lt;/p&gt;

</description>
      <category>git</category>
      <category>bash</category>
      <category>github</category>
      <category>gitlab</category>
    </item>
    <item>
      <title>Delete multiple locals branches in two commands</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Thu, 02 Sep 2021 10:37:51 +0000</pubDate>
      <link>https://forem.com/sanixdarker/delete-multiple-locals-branches-in-two-commands-3daj</link>
      <guid>https://forem.com/sanixdarker/delete-multiple-locals-branches-in-two-commands-3daj</guid>
      <description>&lt;p&gt;Sometimes, we forgot about all branches we're creating when coding, bumping versions, and doing some releases, in result we can have a lot of useless branches in our local project... and it can become frustrating when you need to switch from a branch to another one.&lt;/p&gt;

&lt;p&gt;Soooo, i made a really simple and short bash script to help me delete multiple branch at the same time called &lt;code&gt;gbd&lt;/code&gt;, like &lt;code&gt;git branch delete&lt;/code&gt;, yeahhh yeah i know, too lazy... and the code looks like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# by d4rk3r&lt;/span&gt;

&lt;span class="c"&gt;# this function will loop over the list of branches you provided&lt;/span&gt;
&lt;span class="c"&gt;# and if the branch name is upper than 2&lt;/span&gt;
&lt;span class="c"&gt;# it will delete it&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# $1 can be a file_name or an &amp;lt;&amp;lt;EOF ... EOF&lt;/span&gt;
_del_branch_list&lt;span class="o"&gt;(){&lt;/span&gt;

    &lt;span class="k"&gt;for &lt;/span&gt;bb &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;do
        if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="k"&gt;${#&lt;/span&gt;&lt;span class="nv"&gt;bb&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-ge&lt;/span&gt; 2 &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;then
            &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] Deleting '&lt;/span&gt;&lt;span class="nv"&gt;$bb&lt;/span&gt;&lt;span class="s2"&gt;' branch..."&lt;/span&gt;
            git branch &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$bb&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="c"&gt;# we delete the branch&lt;/span&gt;
        &lt;span class="k"&gt;fi
    done&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# the main function&lt;/span&gt;
main&lt;span class="o"&gt;(){&lt;/span&gt;

    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] Deleting locals branches is my job"&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
    _del_branch_list &lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

main &lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After saving that file and add an alias to it in your &lt;code&gt;.bashrc&lt;/code&gt;, you just have to work with two commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, i need to get the list of commands, and i can have that by hitting &lt;code&gt;git branch&lt;/code&gt;, as an output, i can have :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;  chore/some-bump-here
  chore/some-bump-here
  chore/some-bump-here
  chore/some-bump-here
  chore/some-bump-here
  chore/some-bump-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
  feat/some-feature-here
&lt;span class="k"&gt;*&lt;/span&gt; master
  release/some-release-here
  release/some-release-here
  release/some-release-here
  release/some-release-here
  release/some-release-here
  release/some-release-here
  release/some-release-here
  release/some-release-here
  release/some-release-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I just have to select multiple branches and copy that&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Second, i can jut call the bash script and pass what i just copy in parameters like this (and add at the end the EOF then press ENTER):
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d@k:project$ gbd &amp;lt;&amp;lt;EOF
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt; release/some-release-here
&amp;gt;
&amp;gt; EOF
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting locals branches is my job
&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting &lt;span class="s1"&gt;'release/some-release-here'&lt;/span&gt; branch...
&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting &lt;span class="s1"&gt;'release/some-release-here'&lt;/span&gt; branch...
&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting &lt;span class="s1"&gt;'release/some-release-here'&lt;/span&gt; branch...
&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting &lt;span class="s1"&gt;'release/some-release-here'&lt;/span&gt; branch...
&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting &lt;span class="s1"&gt;'release/some-release-here'&lt;/span&gt; branch...
&lt;span class="o"&gt;[&lt;/span&gt;-] Deleting &lt;span class="s1"&gt;'release/some-release-here'&lt;/span&gt; branch...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source code : &lt;a href="https://gist.github.com/Sanix-Darker/f93b7fc029fc82e37d53693eca8d8471"&gt;https://gist.github.com/Sanix-Darker/f93b7fc029fc82e37d53693eca8d8471&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have FUN !&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>bash</category>
      <category>script</category>
    </item>
    <item>
      <title>git search for code whatever the branch, the time or the commit</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sat, 21 Aug 2021 09:56:41 +0000</pubDate>
      <link>https://forem.com/sanixdarker/git-search-for-code-whatever-the-branch-the-time-or-the-commit-5alf</link>
      <guid>https://forem.com/sanixdarker/git-search-for-code-whatever-the-branch-the-time-or-the-commit-5alf</guid>
      <description>&lt;p&gt;Git has a nice feature called &lt;code&gt;grep&lt;/code&gt;, when you want to get a commit for an old code, and it's a kind of search, but not enough for me !&lt;br&gt;
I wrote a bash script to search for a "piece of code" inside a git project history whatever the branch and time.&lt;/p&gt;

&lt;p&gt;It can :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search a word and return the list of commits where the word was found.&lt;/li&gt;
&lt;li&gt;Switch the project to the target commit, open the file at the specified line, for you, to copy your code, then restore yourself to your working branch !&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we save the file as &lt;code&gt;./gf.sh&lt;/code&gt;, we give execution rights &lt;code&gt;chmod +x ./gf.sh&lt;/code&gt; and we add it in our &lt;code&gt;.bashrc&lt;/code&gt; as an alias : &lt;code&gt;alias gf=${HOME}/gf.sh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can wrote interesting command easily.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gf search &lt;span class="s1"&gt;'vieux code'&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gf open &lt;span class="s1"&gt;'commit-id:fichier:ligne'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how the code looks :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# by d4rk3r&lt;/span&gt;

&lt;span class="c"&gt;# A smart way to search for a code&lt;/span&gt;
&lt;span class="c"&gt;# inside your git history whatever the branch you're&lt;/span&gt;

&lt;span class="c"&gt;# -- Setup :&lt;/span&gt;
&lt;span class="c"&gt;# -- After getting the bash script&lt;/span&gt;

&lt;span class="c"&gt;# chmod +x /path/to/gf.sh &lt;/span&gt;
&lt;span class="c"&gt;# -- to add the execute right to the script&lt;/span&gt;
&lt;span class="c"&gt;# -- You can add it to your .bashrc env&lt;/span&gt;

&lt;span class="c"&gt;# gf s 'pattern' -- to search for some code&lt;/span&gt;
&lt;span class="c"&gt;# -- then after copy the line of the commit,&lt;/span&gt;

&lt;span class="c"&gt;# gf o commit_id:line:file_name....&lt;/span&gt;
&lt;span class="c"&gt;# -- gf will switch to that commit and open the line where the code is,&lt;/span&gt;
&lt;span class="c"&gt;# -- after quitting, gf will restore your repo to the precedent branch where you were working&lt;/span&gt;

_git_search&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="c"&gt;# a smart git command to get commit, file and line where&lt;/span&gt;
    &lt;span class="c"&gt;# the string is available&lt;/span&gt;
    git rev-list &lt;span class="nt"&gt;--all&lt;/span&gt; | &lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="nb"&gt;read &lt;/span&gt;revision&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
            &lt;/span&gt;git &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="nv"&gt;$revision&lt;/span&gt;
        &lt;span class="k"&gt;done&lt;/span&gt;
    &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/.gf-out
&lt;span class="o"&gt;}&lt;/span&gt;

_search&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] Searching for '&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;' in this repo..."&lt;/span&gt;
    &lt;span class="nb"&gt;sleep &lt;/span&gt;2
    &lt;span class="c"&gt;# We less in the list of results&lt;/span&gt;
    _git_search &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/.gf-out | less
&lt;span class="o"&gt;}&lt;/span&gt;

_open_code&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="c"&gt;# getting your current branch&lt;/span&gt;
    &lt;span class="nv"&gt;branch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git branch | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'s/^\* \(.*\)/\1/p'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;# A smart split from the incomming $1 parameter&lt;/span&gt;
    &lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | &lt;span class="nb"&gt;tr&lt;/span&gt; &lt;span class="s1"&gt;':'&lt;/span&gt; &lt;span class="s1"&gt;'\n'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nv"&gt;commit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[0]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[1]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
    &lt;span class="nv"&gt;line&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[2]&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;

    &lt;span class="c"&gt;# some verbose&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] Moving on commit : &lt;/span&gt;&lt;span class="nv"&gt;$commit&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;sleep &lt;/span&gt;1
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] Moving on file : &lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;sleep &lt;/span&gt;1
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] Moving on line : &lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;sleep &lt;/span&gt;1

    &lt;span class="c"&gt;# A checkout on the commit then a less on the line of the file&lt;/span&gt;
    git checkout &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$commit&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    less +&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$line&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$file&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="nb"&gt;sleep &lt;/span&gt;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;[-] Rolling back to your precedent branch..."&lt;/span&gt;
    &lt;span class="c"&gt;# comming back to reality&lt;/span&gt;
    git checkout &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$branch&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

_help_commands&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] gf help center:"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] gf s 'search-kwy-word'"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] gf o 'commit-id:line:file-name'"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

main&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[-] gf started..."&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"search"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"s"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;_search &lt;span class="nv"&gt;$2&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"open"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"o"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;_open_code &lt;span class="nv"&gt;$2&lt;/span&gt;
    &lt;span class="k"&gt;else
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[x] Error: Bad parameter provided..."&lt;/span&gt;
        _help_commands
    &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

main &lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source code : &lt;a href="https://gist.github.com/Sanix-Darker/e571c1fdc2d0a5ecdb9959fecaa3416a"&gt;Gist-Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have FUN !&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>search</category>
      <category>code</category>
    </item>
    <item>
      <title>Asymetric RSA encryption/decryption of your clipboard</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sat, 21 Aug 2021 09:40:25 +0000</pubDate>
      <link>https://forem.com/sanixdarker/asymetric-rsa-encryption-of-your-clipboard-46oj</link>
      <guid>https://forem.com/sanixdarker/asymetric-rsa-encryption-of-your-clipboard-46oj</guid>
      <description>&lt;p&gt;Do you trust your clipboard enough to copy secret information like credentials, tokens, etc... into it ?&lt;/p&gt;

&lt;p&gt;In fact it's possible for an hacker to watch changement from your clipboard and get all text/elements you're copying/pasting, in this case using &lt;code&gt;xclip&lt;/code&gt; !&lt;br&gt;
So i was thinking about a solution on hide what am copying so that if the hacker get the content of my clipboard he will not get anything from it !&lt;/p&gt;

&lt;p&gt;I did asymmetric clipboard encryption using RSA with bash, you can customize the paths of your public/private keys.&lt;/p&gt;

&lt;p&gt;Then I added shortcuts to my system to encrypt the data I'm copying... using &lt;code&gt;Ctrl+Alt+C&lt;/code&gt; instead of &lt;code&gt;Ctrl+C&lt;/code&gt; and to paste, 'Ctrl+Alt+V' instead of 'Ctrl+V'...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# By d4rk3r&lt;/span&gt;

&lt;span class="c"&gt;# This script can :&lt;/span&gt;
&lt;span class="c"&gt;#    - generate keys pair (rsa 2048)&lt;/span&gt;
&lt;span class="c"&gt;#    - rsa encrypt the content of your clipboard/selected element&lt;/span&gt;
&lt;span class="c"&gt;#    - rsa decrypt the content of your encrypted clipboard storage&lt;/span&gt;

&lt;span class="c"&gt;# requirements :&lt;/span&gt;
&lt;span class="c"&gt;# - apt install xclip&lt;/span&gt;
&lt;span class="c"&gt;# - apt install openssl&lt;/span&gt;
&lt;span class="c"&gt;# - apt install xdotool&lt;/span&gt;

&lt;span class="nv"&gt;PUBLIC_KEY_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/.css/darker.pub"&lt;/span&gt;
&lt;span class="nv"&gt;PRIVATE_KEY_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/.css/darker.pri"&lt;/span&gt;

&lt;span class="c"&gt;# the path where the encrypted data will be saved&lt;/span&gt;
&lt;span class="nv"&gt;SECRET_STORE_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/.css/css_secret_store.dat"&lt;/span&gt;


_generate_keys&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HOME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/.css/

    openssl genrsa &lt;span class="nt"&gt;-out&lt;/span&gt; &lt;span class="nv"&gt;$PRIVATE_KEY_PATH&lt;/span&gt; 2048&lt;span class="p"&gt;;&lt;/span&gt;
    openssl rsa &lt;span class="nt"&gt;-in&lt;/span&gt; &lt;span class="nv"&gt;$PRIVATE_KEY_PATH&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; &lt;span class="nv"&gt;$PUBLIC_KEY_PATH&lt;/span&gt; &lt;span class="nt"&gt;-outform&lt;/span&gt; PEM &lt;span class="nt"&gt;-pubout&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

_copy_encrypt&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="c"&gt;# We get the output of xclip and encrypt it&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;xclip &lt;span class="nt"&gt;-o&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; | openssl rsautl &lt;span class="nt"&gt;-encrypt&lt;/span&gt; &lt;span class="nt"&gt;-inkey&lt;/span&gt; &lt;span class="nv"&gt;$PUBLIC_KEY_PATH&lt;/span&gt; &lt;span class="nt"&gt;-pubin&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; &lt;span class="nv"&gt;$SECRET_STORE_PATH&lt;/span&gt;

    &lt;span class="c"&gt;# We save a custom message to the clipboard&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"-css-encrypted-value-"&lt;/span&gt; | xclip &lt;span class="nt"&gt;-i&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

_decrypt_paste&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="c"&gt;# We decrypt using our private key&lt;/span&gt;
    &lt;span class="nv"&gt;string&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;openssl rsautl &lt;span class="nt"&gt;-decrypt&lt;/span&gt; &lt;span class="nt"&gt;-inkey&lt;/span&gt; &lt;span class="nv"&gt;$PRIVATE_KEY_PATH&lt;/span&gt; &lt;span class="nt"&gt;-in&lt;/span&gt; &lt;span class="nv"&gt;$SECRET_STORE_PATH&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c"&gt;# We print to the clipboard de decrypted value&lt;/span&gt;
    &lt;span class="nb"&gt;sleep &lt;/span&gt;0.5&lt;span class="p"&gt;;&lt;/span&gt;
    xdotool getactivewindow &lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$string&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; | xclip &lt;span class="nt"&gt;-i&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

_help_commands&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"./css.sh gen # To generate keys pair"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"./css.sh enc # To encrypt the clipboard selection/saved"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"./css.sh dec # To decrypt the clipboard and put"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# The main function&lt;/span&gt;
main&lt;span class="o"&gt;(){&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"generate"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"gen"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;_generate_keys
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"encrypt"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"enc"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;_copy_encrypt
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"decrypt"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"dec"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
        &lt;/span&gt;_decrypt_paste
    &lt;span class="k"&gt;else
        &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"[x] Error: Bad parameter provided..."&lt;/span&gt;
        _help_commands
    &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

main &lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source code : &lt;a href="https://github.com/Sanix-Darker/css"&gt;github project&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have FUN !&lt;/p&gt;

</description>
      <category>security</category>
      <category>clipboard</category>
      <category>rsa</category>
      <category>encryption</category>
    </item>
    <item>
      <title>Test your entire project(Php, Js, Python, Ruby) with just comments.</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Wed, 10 Mar 2021 16:16:20 +0000</pubDate>
      <link>https://forem.com/sanixdarker/test-your-code-php-js-python-ruby-with-comments-only-4o1c</link>
      <guid>https://forem.com/sanixdarker/test-your-code-php-js-python-ruby-with-comments-only-4o1c</guid>
      <description>&lt;p&gt;Hey there, today am presenting you something really special i made about tests, i hope you're going to like the way i build this solution !&lt;br&gt;
Now, let's jump into it !&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Let's face it frankly, tests are certainly important but they are sometimes extremely boring to write, when you couple that with the fact that each language or each framework has its own way of handling unit tests, it does not help them. things !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh72carv0ynad6ea928d3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh72carv0ynad6ea928d3.jpg" alt="Boring"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I asked myself a fairly simple question, is it possible to manage unit tests in a universal way whatever the programming language "script" or the framework !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxyf4p6apcay5uk6te25.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxyf4p6apcay5uk6te25.gif" alt="solution"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1-) First question: What do all code projects have in common?
&lt;/h2&gt;

&lt;p&gt;The answer is quite simple, the &lt;strong&gt;comments&lt;/strong&gt;; they are the only elements which are present in almost any project, whether it is with a scripting language or a compiled language.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fchvjhuof79i1u2cgn8h9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fchvjhuof79i1u2cgn8h9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2-) Second question: How can we transform simple comments to unit tests ?
&lt;/h2&gt;

&lt;p&gt;Here we are trying to create a system that will do unit tests in a file or a project based on comments, so it was a question for us to define a kind of uniform syntax whatever the programming language in which we are, then create a pseudo test environment like a file in which we put all the elements of testa class and we test the corresponding assertion !&lt;/p&gt;

&lt;p&gt;Behind all of this we would have a cli program that will browse and fetch all tests cases and test them to generate a final report.&lt;/p&gt;

&lt;p&gt;For a simple assertion we end up with something like this :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ::testa_start::
# ::case_start::
# &amp;gt;&amp;gt; testa.isEqual(2, 2)
# &amp;lt;&amp;lt; true
# ::case_end::
# ::testa_end::
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use &lt;code&gt;::testa_start::&lt;/code&gt; and &lt;code&gt;::testa_end::&lt;/code&gt; to surround our pseudo test environment, we can now define a test case with &lt;code&gt;::case_start::&lt;/code&gt; and &lt;code&gt;::case_end::&lt;/code&gt;, then using &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; to define the expected inputs and outputs, here &lt;em&gt;testa.isEqual&lt;/em&gt; just checks if 2 is equal to 2, and we expect a true in output, we also have &lt;em&gt;testa.isSup&lt;/em&gt;, etc ...&lt;/p&gt;

&lt;p&gt;With this structure, we can therefore structure several test cases in a single test pseudo environment in the code :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Inside a python code
&lt;/span&gt;
&lt;span class="c1"&gt;# ::testa_start::
# ::case_start::
# &amp;gt;&amp;gt; testa.isEqual(2, 2)
# &amp;lt;&amp;lt; true
# ::case_end::
&lt;/span&gt;
&lt;span class="c1"&gt;# ::case_start::
# &amp;gt;&amp;gt; testa.isSup(3, 2)
# &amp;lt;&amp;lt; true
# ::case_end:
&lt;/span&gt;
&lt;span class="c1"&gt;# ::testa_end::
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What should be remembered here is that if I want to do the same tests on javascript for example, I just have to replace the comments because, on javascript, the comments per line are &lt;code&gt;//&lt;/code&gt; and not &lt;code&gt;#&lt;/code&gt;; so we are going to have :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Inside a javascript code&lt;/span&gt;

&lt;span class="c1"&gt;// ::testa_start::&lt;/span&gt;

&lt;span class="c1"&gt;// ::case_start::&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;gt;&amp;gt; testa.isEqual(2, 2)&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;lt;&amp;lt; true&lt;/span&gt;
&lt;span class="c1"&gt;// ::case_end::&lt;/span&gt;

&lt;span class="c1"&gt;// ::case_start::&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;gt;&amp;gt; testa.isSup(3, 2)&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;lt;&amp;lt; true&lt;/span&gt;
&lt;span class="c1"&gt;// ::case_end:&lt;/span&gt;

&lt;span class="c1"&gt;// ::testa_end::&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3-) Third question: How to encapsulate a method and define the correct output relative to a precise input ?
&lt;/h2&gt;

&lt;p&gt;Just like the assertion of a simple test case, we define a precise syntax to surround our method !&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ::testa_start::
# ::case_start::
# &amp;gt;&amp;gt; addition(2, 2)
# &amp;lt;&amp;lt; 4
# ::case_end::
# ::code_start::
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;addition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt; This method will return the sum
    of a and b &lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;
&lt;span class="c1"&gt;# ::code_end::
# ::testa_end::
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unlike the simple case tests, here we have &lt;code&gt;::code_start::&lt;/code&gt; and &lt;code&gt;::code_end::&lt;/code&gt; which define the pieces of code that must be taken into account in the pseudo test environment.&lt;/p&gt;

&lt;p&gt;After the execution of the tests in a file/project, testa we generate a test report parraport to the tests which are in success and those which are in failed !&lt;/p&gt;

&lt;h2&gt;
  
  
  4-) Fourth question: How to manage imports from external libraries !
&lt;/h2&gt;

&lt;p&gt;In some cases we often have functions that call external libs or other functions in other files, to solve this problem, I added to the syntax of testa &lt;code&gt;::import_start::&lt;/code&gt; and &lt;code&gt;::import_end::&lt;/code&gt;, this part in a file includes all the imports which will be necessary for the tests in each pseudo environment (files with assertion).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ::import_start::
&lt;/span&gt;&lt;span class="n"&gt;Your&lt;/span&gt; &lt;span class="n"&gt;imports&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt;
&lt;span class="c1"&gt;# ::import_end::
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5-) Fifth question: How to standardize these tests with only one command line.
&lt;/h2&gt;

&lt;p&gt;For this last problem I used the configuration file model, a bit like the &lt;code&gt;package.json&lt;/code&gt; with &lt;em&gt;npm&lt;/em&gt; or &lt;em&gt;yarn&lt;/em&gt;, in this case &lt;code&gt;tesla.json&lt;/code&gt;, but a fairly simple file which describes which directory (file or project) to test, from which language it is and what is the interpreter that must be used, so we have this semblance of structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An example on &lt;code&gt;PHP&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ta-php"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"./square.php"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;".php"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"launcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"php"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;An example with &lt;code&gt;python&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ta-py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"./sha256.py"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./square.py"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;".py"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"launcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"python"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;An example on &lt;code&gt;Ruby&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ta-rb"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"./my_ruby_app/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./square.rb"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"extensions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;".rb"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"launcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ruby"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In conclusion, we can say that we have made a kind of library which works on the CLI allowing to do unit tests whatever the scripting programming language is and to set it up, it's quite simple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgjrsd1fvk4zgz5q832wa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgjrsd1fvk4zgz5q832wa.png" alt="Installation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Testa is a free and open source project, this is some link !&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Source code : &lt;a href="https://github.com/Sanix-Darker/testa" rel="noopener noreferrer"&gt;On github&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;The demo : &lt;a href="https://www.loom.com/share/6d691436356a48ad9ac3ba768459f883" rel="noopener noreferrer"&gt;VIDEO-DEMO&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading, make sure to like, suscribe or leave a comment !&lt;/p&gt;

</description>
      <category>test</category>
      <category>python</category>
      <category>cli</category>
    </item>
    <item>
      <title>Video+Audio conferencing in your terminal !</title>
      <dc:creator>darker</dc:creator>
      <pubDate>Sat, 06 Mar 2021 12:08:07 +0000</pubDate>
      <link>https://forem.com/sanixdarker/video-audio-conferencing-in-your-terminal-3mie</link>
      <guid>https://forem.com/sanixdarker/video-audio-conferencing-in-your-terminal-3mie</guid>
      <description>&lt;p&gt;Yeah i know, what you guys are thinking "Why ?", "Why do you do that ?", well "just for fun ?" and a way to mastering "real-time parallelism", this is also my first POST ever made!&lt;/p&gt;

&lt;p&gt;Let's jump into it !&lt;br&gt;
First of all, a videoconferencing system is a real-time application which consists in broadcasting to each person connected the audio and video stream of all the other participants with the least possible latency !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fic32yegr54gnjvok9ezy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fic32yegr54gnjvok9ezy.png" alt="Video-Conf"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I had to work on the terminal, I only had characters and "bytes" for data entry!&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykdq9eua2b9r8axfmk8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykdq9eua2b9r8axfmk8c.png" alt="Bytes"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  First question : how to transform an image into a perceptible string of characters on a terminal ?
&lt;/h2&gt;

&lt;p&gt;My algorithm is very simple, I first use OpenCv to retrieve the image that the camera /dev/0 device gives me, after that, i convert to black on white using the cvtColor method from OpenCV; then i cut this image into a sort of grid which gives me the color contrast by squares ranging from 0 to 255, I have a sort array equivalence of each pixel! By setting another array of characters ranging from "" to "B", I have a match against the occupancy rate in the pixel !&lt;br&gt;
To complicated ?&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d0zpqixkkzlqp3i5sku.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1d0zpqixkkzlqp3i5sku.png" alt="Complicated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me explain again, more a pixel is dark, the less dense the character will be, so we will have either a "." or a "," with the color value &lt;code&gt;10&lt;/code&gt; or &lt;code&gt;12&lt;/code&gt; unlike "B" or "K" which is closer to &lt;code&gt;250&lt;/code&gt; or &lt;code&gt;255&lt;/code&gt; From there, I manage to have my transcription of a color image in characters on a terminal !&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pap4pv0adhcnb84dt08.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pap4pv0adhcnb84dt08.gif" alt="ASCII"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Second question: how to retrieve the audio stream and transmit it ?
&lt;/h2&gt;

&lt;p&gt;To do this I use PyAudio which connects to the microphone to retrieve the audio stream, then transmit it in the form of bytes per sequences, at the reception, i do a remodeling according to bit rate !&lt;/p&gt;
&lt;h2&gt;
  
  
  Third question: how to send and retrieve the stream(video and audio) for each session ?
&lt;/h2&gt;

&lt;p&gt;Here I am using a byte formatting system in json by adding elements allowing me to identify the one sending and in which session it is sending it, when a client retrieves the data, analyzes it, then retrieves the contents of the package&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyggp0fgsivn2pezlmtz3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyggp0fgsivn2pezlmtz3.png" alt="Sessions"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Fourth question: how does security work in such a system ?
&lt;/h2&gt;

&lt;p&gt;I have implemented two types of data encryption, asymmetric encryption and symmetric encryption, for both systems there is key sharing that needs to be done first, but in the version being tested I have disabled all encryption, as this has an impact on the final rendering quality!&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;AES (Symmetric encryption)&lt;/th&gt;
&lt;th&gt;RSA (Asymmetric encryption)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1gunnuj99qup5euyey3m.png" alt="Alt Text"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4klq1h54rmu6wj2urpg2.gif" alt="Alt Text"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To use s2c, just install it via pip !&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;s2c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the server :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;s2c_server &lt;span class="nt"&gt;-p&lt;/span&gt; 1122
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then start the client :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;s2c &lt;span class="nt"&gt;-s&lt;/span&gt; session1 &lt;span class="nt"&gt;-c&lt;/span&gt; darker &lt;span class="nt"&gt;-i&lt;/span&gt; 127.0.0.1 &lt;span class="nt"&gt;-p&lt;/span&gt; 1122
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can use help to see the manual :&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnf830zhk0e177ktq00es.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnf830zhk0e177ktq00es.png" alt="Manual"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, all this article would be useless without a DEMO: &lt;a href="https://www.loom.com/share/3692b64a140a4b8e87d2a0319f8ae3d5" rel="noopener noreferrer"&gt;WATCH ME&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;s2c is Open Source and free !&lt;/p&gt;

&lt;p&gt;Source Code : &lt;a href="https://github.com/sanix-darker/s2c" rel="noopener noreferrer"&gt;https://github.com/sanix-darker/s2c&lt;/a&gt;&lt;br&gt;
Pypi-Package :  &lt;a href="https://pypi.org/project/s2c/" rel="noopener noreferrer"&gt;https://pypi.org/project/s2c/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PS : Any comments or constructive advice are welcome !&lt;/p&gt;

</description>
      <category>python3</category>
      <category>opencv</category>
      <category>pyaudio</category>
      <category>numpy</category>
    </item>
  </channel>
</rss>
