Posts

Hiding YouTube comments section

Image
 Yes , reading YouTube comments is fun. But reading too many YouTube comments can lead you take a deep dive into the dark bottomless pit of irrelevant internet crap. Therefor , your man with a plan Mr. Gabs has the following solution to get rid of this for good.  ( I will probably delete this post If I ever go for an interview at Goggle ) Anyways  , steps to achieve Liberation from YouTube comments : 1. Get GreaseMonkey or TamperMonkey , if you use any other browser then we can't be friends 2. Read This to get an idea on how it works 3. Take this script which I copied from stackoverflow with my own bear hands and use it to achieve your goal // ==UserScript== // @name         Hide youtube comments // @namespace    http://tampermonkey.net/ // @version      0.1 // @description  In memory of the guy who wrote this // @author       You // @match        https://www.youtube.com/* // @icon         https://www.google.com/s2/favicons?domain=youtube.com // @grant        none // ==/UserScript=

GIT Cherry Picking

Image
 Ever had a colleague telling you "hey bro can you please have a look at this commit ?" , or you tell a colleague "hey bro , please check the changes i made with this commit" ? Basically someone else asking you to check the changes they made with a specific commit ? In such a case how do you get the files by a specific commit to your local computer ? Well me , until today , I have been copying those files manually to my local like an idiot. But just now I found out that you can use the built in git command of git cherry-pick for this kind of work!  Just type git cherry-pick <commit-hash> and you can get your buddy's code onto your local with a blink of an eye. This will automatically commit the commit to your local though , so if you are a man of culture like me just use  git cherry-pick -n  to stop it from committing. This still stages the changes but least you can have a look at the diff easily this way. I'm pretty sure there must be plenty of other

Marker Interfaces

 So today I was doing some coding on a personal project and I had this scenario where I have a class that contains an object representing some data , but the nature of this data is very diverse so I could not create an interface to represent it. But I do needed to "mark it" as something belonging to an expected type. So what did I do ? Well nothing :P , I was using typescript and I left that member type as "any" but that looked so ugly to me so I had to do something! So after thinking for a while I thought "Ok , I will have an empty interface ! To mark my classes. But are empty interfaces even allowed??" . So I googled my concern and found out that it is indeed a thing and it is called a Marker Interface. https://en.wikipedia.org/wiki/Marker_interface_pattern So basically marker interface means an empty interface that you use to mark something. But it does have a lot of bad side effects according to SO and many other online platforms and in modern language

Angular Mysterious Routing

Image
 I was working on an Angular app and one fine day I imported a module into another module. After doing so I noticed that the routing on my importee ( or whatever tf it's called ) is not working and it is replaced by the routing , of the imported module.  After wasting a few good minutes I found out that the reason for this mysterious behavior is the ORDER in which you import these modules. If you import the imported module before the routing module of your importee module , then the visitor's routing will take over yours.   Following screen shots explains this with sample modules. The file shown here is the innocent.module.ts   which is my importee. ImportedModule is the imported module. OK This order is OK as the InnocentRoutingModule is imported before   ImportedModule . All good! NOT OK This order is NOT OK as the  InnocentRoutingModule  is imported  after   ImportedModule .  Imported module routing will therefor take over , bad Angular bad !  So that's it guys ! Be mind

PowerShell Script to combine a simple image and audio -> Export to video

Image
 So , I was doing some stuff on YouTube and i have this specific requirement where i often need to combine a few audio clips with a simple image and create a simple video. Nothing fancy just one short audio clip + one simple image -> export to video  ,that's all I want.  I have been doing it manually by using the free video editor OpenShot  , but since there is not editing done here at all and all i do is just combine , i thought of writing a PowerShell script to get it done. I'm using the popular ffmpeg  library for this and i think the script is self explanatory. I'm sharing the script below so please feel free to use it if you wish :) . Hoping to do some changes to it later and make it upload the exported video to YouTube so the complete workflow is covered. I think i should be able to do it with YouTube API so we'll see. Here is my script on GitHub !

With Values

Image
 Using the clause WITH VALUES when you are adding a new column to an existing table using Microsoft SQL Server is a handy little trick. The use of WITH VALUES is when you want to add a default constraint to an existing table that allows null . Because when you add a default constraints that allows null it will NOT fill the existing rows with a value, this can effect your database logics ( if you have written some code depending on these values ).  Let me demonstrate this with some simple tables. Create a simple table CREATE TABLE Students( id int NOT NULL, name varchar(50) NULL ) Add some sample data insert into Student (id,name) values (1,'Cappadonna'), (2,'UGod') Add a new column to the table , with NOT NULL  clause ALTER TABLE Student ADD age int not null CONSTRAINT age_default DEFAULT 99 Now if you query your table you will see that the existing rows are being populated with your default value. This is because we added the constraint as NOT NULL.    Now let

Wasted about an hour of my life on something so trivial

Image
 Ok guys so i wasted about an hour trying to figure out how to bind to the "disabled" property in a textbox in angular. And after trying for a long time i realized that my code is not working as expected because , you have to use null instead of "false" to control it. Please refer to the stackoverflow answer below. Darn it ! https://stackoverflow.com/questions/42179150/how-to-disable-a-input-in-angular2/43765804