<?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: Talha Aamir</title>
    <description>The latest articles on Forem by Talha Aamir (@sarcxd).</description>
    <link>https://forem.com/sarcxd</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%2F186932%2F47ec5f64-957d-4874-b2a2-231f79a7bf45.jpg</url>
      <title>Forem: Talha Aamir</title>
      <link>https://forem.com/sarcxd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sarcxd"/>
    <language>en</language>
    <item>
      <title>Killer cross platform pdf reader</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Sat, 24 Sep 2022 15:09:21 +0000</pubDate>
      <link>https://forem.com/sarcxd/killer-pdf-cross-platform-reader-4pgp</link>
      <guid>https://forem.com/sarcxd/killer-pdf-cross-platform-reader-4pgp</guid>
      <description>&lt;p&gt;Project links:&lt;/p&gt;

&lt;p&gt;project-demo: &lt;a href="https://readsyncpdf.web.app/"&gt;https://readsyncpdf.web.app/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
front-end: &lt;a href="https://github.com/sarcXD/read-sync-pdf/"&gt;https://github.com/sarcXD/read-sync-pdf/&lt;/a&gt;&lt;br&gt;&lt;br&gt;
back-end: &lt;a href="https://github.com/sarcXD/read-sync-server"&gt;https://github.com/sarcXD/read-sync-server&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Alright, what is this?
&lt;/h2&gt;

&lt;p&gt;readsyncpdf (stupid name, yes) is an app that allows you to read pdf files. You can upload a pdf (I think it has a 20mb limit). It will then keep track of how much you have read. So  the next time you want to read something, you just go to the website (on any device), login and it will load the pdf right where you left off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Okay, why did you make this?
&lt;/h2&gt;

&lt;p&gt;I built this when I was having trouble reading books or papers. I blamed my environment. I had to switch A LOT!! between my laptop, desktop pc and mobile. To make matters worse I was dual booting on my laptop, so goodbye to anything I read and forgot about. I then decided to make something that could fix this pain point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Did I succeed??
&lt;/h2&gt;

&lt;p&gt;YEAH, I wanted to read a book one day, I started off on my laptop, eventually when I wanted to play some games and stop working, I shifted to my desktop reading it there. Eventually when I got tired I just lay on my bed, opened it on my phone and read it there. AMAZING!!&lt;/p&gt;

&lt;h2&gt;
  
  
  Why open source
&lt;/h2&gt;

&lt;p&gt;well, several reasons, mainly, none of the people who read books amongst my friends used it, because well they had dedicated devices to read books and they used epub as a format. I realised this was a niche and as much as I would have liked this to be a service, I honestly wanted to do and make other things as well, and I didn't have an indicator of whether this would be successful. THUS, I open sourced it. I also wanted to have some opensource React code that I could show, since I have very little of that even though I've built a ton of &lt;em&gt;NDA&lt;/em&gt; stuff.&lt;/p&gt;

&lt;p&gt;HAVE FUN. I stopped maintaining this a while ago, and might pick it up based on the interest in it, but for now I guess the repo just remains public and requiring a buncha fixes and updates.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>showdev</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>Fixing an annoying Whatsapp "feature"</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Fri, 16 Sep 2022 22:12:30 +0000</pubDate>
      <link>https://forem.com/sarcxd/fixing-an-annoying-whatsapp-feature-3nlp</link>
      <guid>https://forem.com/sarcxd/fixing-an-annoying-whatsapp-feature-3nlp</guid>
      <description>&lt;p&gt;This is a short post. Whatsapp had the archived chat feature for a while, I started finding it annoying at a point since I would keep track of the number:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TxL_IhLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/op2no3ptch2co4bh41cg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TxL_IhLx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/op2no3ptch2co4bh41cg.png" alt="archived count" width="322" height="37"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, I thought maybe I could write a script, perhaps an extension to hide it, since well, I was able to do as much with devtools by inspecting and adding &lt;code&gt;display:none&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
It's janky but it works, I mean all it needs to do is upon the page load, get the element of the div with the number by classname, and add the style &lt;code&gt;display:none&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
Seems pointless, but well it was fun little thing to find I could do.&lt;br&gt;
Here's how it looks after it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d3WOw9Op--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/deioj09d9pfyvr5v9gvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d3WOw9Op--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/deioj09d9pfyvr5v9gvq.png" alt="No archived count" width="380" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the script,&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/sarcXD/harch-wa-ch"&gt;chrome&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/sarcXD/harch-wa-ff"&gt;firefox&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;P.S. Haven't documented adding it, probably cause I've been the only one using it.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Cover Letter Generator - Prototype</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Tue, 06 Sep 2022 21:32:19 +0000</pubDate>
      <link>https://forem.com/sarcxd/cover-letter-generator-prototype-5973</link>
      <guid>https://forem.com/sarcxd/cover-letter-generator-prototype-5973</guid>
      <description>&lt;p&gt;I'm showcasing a cover letter generation tool I prototyped for fun a while back. This doesn't use any deep learning, or anything fancy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/sarcXD/covlet-gen"&gt;LINK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The idea is simple: you define a set of templates, and when running the tool can specify things like company name, role name, and achievements/things to showcase in the cover letter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivations
&lt;/h2&gt;

&lt;p&gt;Mainly, this was written at a point where I was a bit tired and confused with just how many variants of cover letters I'd need to write.&lt;br&gt;&lt;br&gt;
So, I'm a full stack engineer but I can apply to multiple roles&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Front-end&lt;/li&gt;
&lt;li&gt;Back-end&lt;/li&gt;
&lt;li&gt;Full-stack&lt;/li&gt;
&lt;li&gt;software-engineer
And since each job and company is different there requirements require tuning the cover a bit every so often to match or highlight achievements that they want to see. That's when I reached this point. I wanted to see if I could make a utility that would simplify that process a bit. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cool Features
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You can specify a template, then generate an cover letter based on your requirements at run-time.&lt;/li&gt;
&lt;li&gt;You can choose to either copy the generated cover-letter to your clipboard OR,&lt;/li&gt;
&lt;li&gt;Generate a pdf, I do this using Fpdf.&lt;/li&gt;
&lt;li&gt;a simple JSON datastore to track if you've already generated a cover letter for this role and company (for...reasons).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's something I wanted to make, and see if it would be useful, and... it was slightly. What doesn't work is that the sentences seem a bit awkward, as I need to figure out the connectors between each achievement section.&lt;/p&gt;

&lt;p&gt;Thats it,&lt;br&gt;
Thanks&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>python</category>
    </item>
    <item>
      <title>destroying git push --set-upstream origin with vim</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Mon, 10 Jan 2022 13:07:57 +0000</pubDate>
      <link>https://forem.com/sarcxd/destroying-git-push-set-upstream-origin-with-vim-4k9n</link>
      <guid>https://forem.com/sarcxd/destroying-git-push-set-upstream-origin-with-vim-4k9n</guid>
      <description>&lt;p&gt;I hate that everytime I need to push a new branch to my origin I need to go through the painful process of &lt;br&gt;
&lt;code&gt;git push --set-upstream origin ${branch-name}&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
The problem is worse because I need to type and tab complete the branch name too, just too much hassle.&lt;br&gt;&lt;br&gt;
Now with vim I had the thought to one day just make a remap, which I did, and what that did was basically just type out the statement&lt;br&gt;&lt;br&gt;
&lt;code&gt;:Git push --set-upstream origin&lt;/code&gt; and allowed me to just type the branch name.&lt;br&gt;&lt;br&gt;
I think today even that was too much repetition for me, so I had the idea to see how more could I reduce this. I mean I wanted to learn vimscript anyhow, so was a nice thing to do.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The Vim Magic
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;" For new branch
" gets branch name
" sets upstream origin automatically
function! GitPushUpsOrgBranch()
  let branch = system("git branch --show-current")
  let push_str = "git push --set-upstream origin ".branch
  let conf_msg = "Do you want to execute\n".push_str
  let conf_res = ConfirmBox(conf_msg)
  if conf_res == 1
    let push_str_out = system(push_str)
    echo push_str_out
  endif
  return 1
endfunction

" git push set upstream remap
nnoremap&amp;lt;silent&amp;gt; &amp;lt;Leader&amp;gt;gpsu :call GitPushUpsOrgBranch()&amp;lt;CR&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;What this beautiful set of commands does is that upon hitting gpsu it makes vim call the function &lt;strong&gt;GitPushUpsOrgsBranch()&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  GitPushUpsOrgsBranch
&lt;/h3&gt;

&lt;p&gt;This does 3 things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Gets my current branch which git 6.6+ allows (I think, don't remember) via
&lt;code&gt;
git branch --show-current
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Appends it to a string and forms the actual bland repetitive command I so hate
&lt;code&gt;git push --set-upstream origin ${branch_name}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Before pushing it actually prompts me and then allows me to push. (see image below)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Id69hb3t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z48u8rzz6v0iuaovel24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Id69hb3t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z48u8rzz6v0iuaovel24.png" alt="Git destroys set upstream" width="847" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;This was a comfortable way to get into vimscript, but also was a nice personalization I deeply enjoyed. Pretty cool stuff.&lt;/p&gt;

</description>
      <category>vim</category>
      <category>vimscript</category>
      <category>git</category>
    </item>
    <item>
      <title>A unique text jumbling animation using css</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Mon, 27 Dec 2021 06:42:12 +0000</pubDate>
      <link>https://forem.com/sarcxd/a-unique-text-jumbling-animation-using-css-1gif</link>
      <guid>https://forem.com/sarcxd/a-unique-text-jumbling-animation-using-css-1gif</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I made a minimalistic yet clean (as much as I could) portfolio using only html and css a while back, and wanted to highlight two of the animation/designs that I really liked and designed myself (even if they weren't completely unique). I had been thinking of updating my portfolio so before I proceeded with that I wanted to create a few posts highlighting each of the things that I liked the most in the entire project.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;This is part 1&lt;/strong&gt;, the text jumbling animation I stumbled across by pure chance, and some trial and error.  &lt;/p&gt;
&lt;h3&gt;
  
  
  NOTE
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://sarcxd.github.io/#page1" rel="noopener noreferrer"&gt;portfolio site&lt;/a&gt; - If you are interested or just want to see my portfolio site (more posts coming, hopefully)&lt;br&gt;
The animation the post concerns, (in case you did not view it in the cover, is this)&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%2Fqiuwykr356asmc01e2sd.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%2Fqiuwykr356asmc01e2sd.gif" alt="Text Jumbling Animation Demo"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Animation Description
&lt;/h2&gt;

&lt;p&gt;I will first mention, that I initially intended this to be a sort of a typewriter effect but because of some styling I made, it came out abit wrong, giving me the idea of trying something new.&lt;br&gt;&lt;br&gt;
Let's go through it, step by step&lt;br&gt;
The code of interest in my &lt;code&gt;index.html&lt;/code&gt; is my intro, where I apply the style &lt;code&gt;intro-txt&lt;/code&gt; to the entire div&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%2F0jpnsym8yfuwhbopx7w6.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%2F0jpnsym8yfuwhbopx7w6.png" alt="Html file image"&gt;&lt;/a&gt;&lt;br&gt;
Let's now look at the styling where I will try to explain what I did.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.intro-txt {
  font-family: emberly;
  font-size: 2em;
  color: #d2b48c;
  letter-spacing: 1px;

  /* The sauce */
  animation: textJumble 1.5s ease-in 0s 1 normal forwards;
  /* 
    This gives us the cut off effect as if, text is appearing on 
    the screen in a jumbled manner. 
  */
  overflow-x: hidden;
  overflow-y: hidden;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The actual animation is extremely simple, which even going back to it now, does surprise me. (yes, I have in fact forgotten a lot of what I did)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframes textJumble {
  0% {
    width: 0;
    height: 109px;
  }

  100% {
    width: 100%;
    height: 109px;
    white-space: normal;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Basically, it starts off with a width of 0, till a width of 100%, which I have defined in the parent container of my text box as &lt;code&gt;500px&lt;/code&gt;. This allows the text to be populated from the bottom up, as the height never changes. It also makes the text incomprehensible during the animation adding to the jumbling effect that it comes off as.&lt;/p&gt;

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

&lt;p&gt;You can view the code &lt;a href="https://github.com/sarcXD/sarcXD.github.io" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;strong&gt;Spoilers!&lt;/strong&gt; The styling file is well, it might be a bit confusing so I expect a lot of you might not be big fans of it.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>showdev</category>
      <category>portfolio</category>
    </item>
    <item>
      <title>Conditional Debugging - Faster debugging for complicated cases</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Mon, 13 Dec 2021 04:50:24 +0000</pubDate>
      <link>https://forem.com/sarcxd/conditional-debugging-faster-debugging-for-complicated-cases-pg9</link>
      <guid>https://forem.com/sarcxd/conditional-debugging-faster-debugging-for-complicated-cases-pg9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;My main goal with this small post is to just point out that if you're someone who doesn't use conditional breakpoints, when:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you're investigating a bug&lt;/li&gt;
&lt;li&gt;know a case (some id or some value) you want to verify
&lt;/li&gt;
&lt;li&gt;are continually hitting the continue or step next button &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; For the TLDR of this post in a short gif, skip to conditional debugging&lt;/p&gt;

&lt;p&gt;Well, you should (be using conditional breakpoints). Its a pretty simple feature which most (if not all) debug tools support. I have no idea how I skipped past this, probably because I never realized I could do this in the first place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveat
&lt;/h2&gt;

&lt;p&gt;At the time of writing, I have been using this for python debugging using pycharm, c++ debugging using visual studio and javascript debugging in chrome devtools, and it seems to be atrociously slow in devtools at my work atleast, even for an array with a few 100 entries, not a complicated process at all, but a bug I imagine. Either way, it's worth testing out yourself&lt;/p&gt;

&lt;h2&gt;
  
  
  Process
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;I'll take chrome dev tools as an example here, I have created a very simple project, with an html file that has a &lt;code&gt;button&lt;/code&gt; with a function &lt;code&gt;printEvenTillN&lt;/code&gt;. This as you might image &lt;em&gt;prints all even numbers till N&lt;/em&gt;.&lt;br&gt;
I have another js file, what this has is the function itself.&lt;br&gt;
I have used the Live Server extension to launch a server so I can debug this in chrome devtools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conditional Debugging
&lt;/h3&gt;

&lt;p&gt;The Case I am presenting is that for our simple function &lt;code&gt;printEvenTillN&lt;/code&gt; I want to see if &lt;strong&gt;32&lt;/strong&gt; is amongst the numbers it prints. I am choosing a specific number because it translates well to complicated debugging cases where we want to see if say a particular element with some known unique id exists.&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%2F6nxwgz65eqe64pacfeyq.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%2F6nxwgz65eqe64pacfeyq.gif" alt="Conditional Debugging Demo"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I hope you get some value out of it. If you did not know about this already I encourage you to try it. Whilst console logs and looping through each debug instance is well, easy, and we are sometimes lazy, this makes the process so much easier.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>devtools</category>
      <category>debugging</category>
    </item>
    <item>
      <title>SqlAlchemy: simplify complex joins</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Wed, 05 May 2021 19:13:19 +0000</pubDate>
      <link>https://forem.com/sarcxd/sqlalchemy-simplify-complex-joins-1nea</link>
      <guid>https://forem.com/sarcxd/sqlalchemy-simplify-complex-joins-1nea</guid>
      <description>&lt;p&gt;I am writing this article after coming across the same issue a second time and having to spend a good chunk of time figuring my issue out. I found this to be a super sweet feature that sqlAlchemy allows us to do, and since I can abstract away the sqlAlchemy calls, making the code and my thinking a bit simpler than if I were to do it using simple sql.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;I have two tables, and for my case, I need to join the results of an sql query in one table with the results of an sql query in another table.&lt;br&gt;
While I cant show the exact endpoint, I will give a lay of the land, and setup 2 sample tables and a usecase that I hope will demonstrate the problem well.&lt;/p&gt;
&lt;h2&gt;
  
  
  The DB Setup
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Books Table
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;location_in_library&lt;/th&gt;
&lt;th&gt;price&lt;/th&gt;
&lt;th&gt;author&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Bookmarks Table
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;id&lt;/th&gt;
&lt;th&gt;page_number&lt;/th&gt;
&lt;th&gt;book_id&lt;/th&gt;
&lt;th&gt;bookmark_date&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In the case of these tables, suppose we have a case:  &lt;/p&gt;
&lt;h3&gt;
  
  
  Simple Query
&lt;/h3&gt;

&lt;p&gt;fetch bookmark_date, for existing books. If a book does not have any bookmarks, we would like to show it (using some processing in the endpoint, does not concern us how that happens).&lt;br&gt;&lt;br&gt;
How to go about doing that? well here it is simple, just do a join on the basis of Books.id == Bookmarks.book_id. &lt;/p&gt;
&lt;h3&gt;
  
  
  Complicated Query
&lt;/h3&gt;

&lt;p&gt;How do we proceed in the case of a more complicated query though? Say, For books having a location like X in the bookshop, we want to fetch their price, author information, as well as the number of bookmarks they have. &lt;br&gt;
What I find to be a really intuitive approach here is to utilize what sqlalchemy calls subqueries. Sql also has subqueries, but instead of being written in the same line of code, these feel like more of an isolation. I really like how simple an operation like this can be made in sqlalchemy, greatly improving readability and the time I spend figuring out the query.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using SqlAlchemy
&lt;/h2&gt;

&lt;p&gt;Lets split this complex query, rather easily into different parts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For books having a location like X, return price, author information
&lt;/li&gt;
&lt;li&gt;Fetch number of bookmarks for the book
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In sqlalchemy this will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Book and BookMark are the sqlalchemy classes corresponding
# to each table
books = Book.query.filter(Book.location == X) \
        .with_entities(Book.id.label('book_id'), \
        Book.location.label('location'), \
        Book.price.label('price'), \
        Book.author.label('author')).subquery()
bookmarks = BookMark.query.with_entities( \
            BookMark.book_id.label('book_id') \
            func.count(BookMark.id).label(bookmark_count)) \
            .group_by(BookMark.id).subquery()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now here we have separated out books, and bookmarks into 2 individual subqueries, and can just think about them in terms of what each contains. All we need to do is join them, and we can do that as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# The reason we do books.c.book_id is to index the column of
# a particular subquery
res = db.session.query(books.c.book_id, \
      books.c.location, books.c.price, \
      books.c.author, bookmarks.c.bookmark_count) \ 
      .join(books, books.c.book_id == bookmarks.c.book_id)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And, that is it. That is all we need to do to get this and even more complicated queries, maybe something requiring more operations from each or a single table.  &lt;/p&gt;

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

&lt;p&gt;This was an example I replicated from something I was working on at work, of course, I cant show exactly that, but my problem was similar to that of the example shown. I had tried looking around a bunch of blogs and stack exchange posts failing to find a good way of implementing this in SQL. I later realized that I would have had to port that SQL to sqlAlchemy code. This in my opinion works better just development-wise, because we are able to abstract out the two complicated queries, thinking just in terms of data we need, and not getting too involved in the syntax or ordering.&lt;br&gt;&lt;br&gt;
Anyways, hope this helps.&lt;/p&gt;

</description>
      <category>python</category>
      <category>sql</category>
      <category>sqlalchemy</category>
    </item>
    <item>
      <title>Postman: how to send api requests w/t json objects</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Wed, 05 May 2021 08:57:29 +0000</pubDate>
      <link>https://forem.com/sarcxd/postman-how-to-send-api-requests-w-t-json-objects-277b</link>
      <guid>https://forem.com/sarcxd/postman-how-to-send-api-requests-w-t-json-objects-277b</guid>
      <description>&lt;p&gt;Postman is, at this point probably, &lt;strong&gt;the tool&lt;/strong&gt; used to run and test application endpoints. As you might imagine, especially for working on in-progress or already developed feature even, it is faster and convenient to quickly test your endpoints instead of manually running a flow and waiting to see if an endpoint returns fine.&lt;br&gt;&lt;br&gt;
I needed to go back to using postman for an in-progress feature and thought it would be nice to have this article for future reference for myself and for anyone else. Especially, since this took me a few mins to properly set up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;I'm using Ubuntu, so I just used the snap store to install:&lt;br&gt;
&lt;code&gt;sudo snap install postman&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Objectives
&lt;/h2&gt;

&lt;p&gt;The request I want to test   &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;is a POST request&lt;/li&gt;
&lt;li&gt;uses authentication&lt;/li&gt;
&lt;li&gt;uses a json object, to pass data
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;This section will have a few screens for clarity and so its easier, and maybe faster to skim through&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set your request type and fill in your endpoint url
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bURpuOFU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k1lphq8vz05tk75ja4wa.png" alt="Endpoint url and request setup"&gt;
&lt;/li&gt;
&lt;li&gt;Since the endpoint has authentication, you can navigate to the authorization section, and select and set your corresponding authorization token/credentials. For me its a basic authentication token.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Uiy42uWE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yj1or7i258o30but5s7n.png" alt="Authentication Token"&gt;
&lt;/li&gt;
&lt;li&gt;Finally, since we have a json object, it is supposed to be passed in the body tab. I am using test data to demonstrate how to go about doing it. Since we are sending json data, I switched the input type to raw, which allows us to write raw text, and changed the type from text to json, just so postman gives us some nice highlighting
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aYcccxKP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8h0cdmggzfc66uviwzs.png" alt="Json Object Filling"&gt;
Once done we can save, and run the endpoint, and it will return data, or an error in case it fails.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>postman</category>
    </item>
    <item>
      <title>Document your Typescript Project in 5 mins - typedoc</title>
      <dc:creator>Talha Aamir</dc:creator>
      <pubDate>Thu, 18 Mar 2021 07:10:22 +0000</pubDate>
      <link>https://forem.com/sarcxd/document-your-typescript-project-in-5-mins-typedoc-3ilm</link>
      <guid>https://forem.com/sarcxd/document-your-typescript-project-in-5-mins-typedoc-3ilm</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;typedoc is a fairly simple and easy library to setup, and its benefits are in how you document your codebase. The library itself is also really popular, and commands for adding comments are pretty straightforward. Most of the type inference is done by typescript itself, which gives you fewer things to worry about.&lt;/p&gt;

&lt;h2&gt;
  
  
  Official Documentation
&lt;/h2&gt;

&lt;p&gt;If instead or in addition to this article, you wanted to go to the offical website (which is highly recommended) &lt;a href="https://typedoc.org/guides/installation/" rel="noopener noreferrer"&gt;click here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;To install the typedoc package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install typedoc --save-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can verify if it works by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx typedoc --version

TypeDoc 0.20.0
Using TypeScript 4.1.2 from /home/gerrit/typedoc/node_modules/typescript/lib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Now that we have installed the library, we can generate a documentation to get the gist of how it works.&lt;/p&gt;

&lt;p&gt;To keep things simple, this is what you need to care about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Where the generated documentation should be outputted&lt;/li&gt;
&lt;li&gt;Which source files should be used&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We specify the output directory using the --out parameter followed by the path to output directory.&lt;br&gt;
Anything declared without a flag 'eg, --out' will be treated as a source file and will be parsed for generating documentation&lt;br&gt;
We can run this command to generate a documentation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ typedoc --out docs/ src/app/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of the src/app/ folder you can also point to your applications entry point, which for a react project would be your src/index.ts file. Typedoc treats file and folder locations differently. If you point to a folder it will treat all files inside that folder as individual entry points. If you point to a file, which typedoc says should be your applications entry point, it will generate documentation for the module that file exports.&lt;/p&gt;

&lt;p&gt;Heres how the generated document looked for my project&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%2F1sd1m0mkm0x4rxengyto.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%2F1sd1m0mkm0x4rxengyto.png" alt="Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When you open the index.html file for your documentation, this is what is displayed, if your project has a readme.md, you'll be greeted to a preview of it. The explorer menu on the right lists all the modules typedoc found and generated documentation for in your project.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I was running into issues generating a documentation when pointing to what is supposed to be my projects entry point. I think this might be due to the fact that the project I am generating this for, is an Angular project, I am using a source folder instead of an entry point file, because in Angular entry points are treated differently. Angular instead provides a compilation of files, instead of a fixed entry point. &lt;a href="https://stackoverflow.com/questions/54862163/where-is-the-entry-point-specified-in-angular-application/54862588" rel="noopener noreferrer"&gt;see here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  How the documentation is displayed
&lt;/h3&gt;

&lt;p&gt;This part is fairly straightforward, and ill illustrate using an example component.&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%2Fx28ez7gabjlkavs91fcn.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%2Fx28ez7gabjlkavs91fcn.png" alt="Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is a preview of the documentation typedoc will generate for just 1 component, which in this case is an example-component I created with some basic properties and methods.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I havent commented anything, but luckily for us, typedoc generates a barebones documentation for our functions as well.&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%2F6lc4fqudwbikxov0dks0.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%2F6lc4fqudwbikxov0dks0.png" alt="Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;All of this has been generated by typedoc automatically!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Adding documentation comments
&lt;/h3&gt;

&lt;p&gt;Now that we have an idea of how it works, we will move on to the final section, adding comments, and utilizing some basic typedoc tags namely &lt;code&gt;@param&lt;/code&gt; and &lt;code&gt;@return&lt;/code&gt;.&lt;br&gt;
I'll add some nice little descriptions to my greetings function&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%2Fzz461dz4ikc3c1keacu0.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%2Fzz461dz4ikc3c1keacu0.png" alt="image"&gt;&lt;/a&gt;&lt;br&gt;
I run the command to generate the documentation again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx typedoc --out docs src/app/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if we navigate to our example component again we can see the updated documentation&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%2F7xsro75vuqctn269tkok.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%2F7xsro75vuqctn269tkok.png" alt="Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Isn't this great? that's all it took to generate a pretty-ish but useful documentation.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;typedoc uses markdown for generating its documentation, so I guess if you wanted to you could even add a heading tag in a comment and get this&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%2Fjget9tx8mghs5k36rd1j.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%2Fjget9tx8mghs5k36rd1j.png" alt="Image"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;You should now have some idea about how typedoc works, how to generate a basic documentation and how to add your own code comments. More than that however, I hope this makes you more willing to add documentation your codebase.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>documentation</category>
    </item>
  </channel>
</rss>
