Skip to content

Instantly share code, notes, and snippets.

View swapnilraj's full-sized avatar

Swapnil Raj swapnilraj

View GitHub Profile
@swapnilraj
swapnilraj / subList.js
Last active August 29, 2017 10:07
Javascript snippet to get the name of subscriptions and channel links on Youtube.
(() => {
let subs = Array.from(document.querySelectorAll('#sections > ytd-guide-subscriptions-section-renderer > div#container > ytd-guide-entry-renderer')).map(
e => `${e.querySelector('span.title').innerText} - ${e.querySelector('a').href}`,
);
if (subs.length === 0) {
subs = Array.from(document.querySelectorAll('#guide-channels > li.guide-channel')).map(
e => `${e.querySelector('span.display-name').innerText} - ${e.querySelector('a').href}`,
);
}
const subList= JSON.stringify(subs, undefined, 2);
@swapnilraj
swapnilraj / Graph.java
Created November 3, 2017 15:11
Implementation of a Graph in Java. Testing with different kinds of implementation.
// Copyright 2017 Swapnil Raj<sr@sraj.me>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
@swapnilraj
swapnilraj / keybase.md
Created March 23, 2018 21:00
Gist to verify github account to Keybase <3

Keybase proof

I hereby claim:

  • I am swapnilraj on github.
  • I am rajs (https://keybase.io/rajs) on keybase.
  • I have a public key ASChJTyL_0wTG4XLqDSoKnWW9Ht5rM8dnZF522KUOC3Tgwo

To claim this, I am signing this object:

@swapnilraj
swapnilraj / bubba.bf
Last active December 7, 2018 23:36
bubba-brainfuck
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>
++++++++++
<<
[b.> u.> n> c[>+ <<<<.>>> -] > [-<+>]<+ <<<b..-.+ >>n. <<]

Brief

With the new changes coming in the MutationObserver branch; we discovered the title of the Youbube page is always the same as the title of the page and instead of doing an expensive call to the document with a query selector for the title of the video which is a nested DOM element we can use the document title.

The MutationObserver branch also makes all the lyric logic depend on the change in the title of the web-page; coupled with this change there is a nice

@swapnilraj
swapnilraj / Lyricist - Fix title parser for - separator.md
Last active December 31, 2018 15:55
Lyricist = Proposal for fixing issue 11

Title extraction fix

This fix is addressing the issue #11, to explain the issue in detail; the current extraction is done using regular expressions and the current expression used is /(.*)(\||\/\/\/|-|:)(.*)(\s-\sYouTube)$/. The issue with this expression is the eager nature of the regex engine where it tries to capture the biggest expression possible.

This document is also an attempt at documenting the rather big regular

@swapnilraj
swapnilraj / Lyricist - Add unit tests.md
Last active December 31, 2018 13:48
Document describing an approach to add unit tests to the project.

Description

As stated in our discussion while version 3.0.0 was being released we need to add tests to the project for several reasons, one of them being to easily verify new changes and make sure they don't break the project. The tests will also help keep track of the edge cases for future reference. This document is concerned only with unit tests but we will work in the future to add e2e testing.

Approach

Description

This change is a part of a bigger module and change relating to detecting music videos based on certain heuristics. This module detects if a video is a music video by checking for the verified artist icon next to the channel name.

YouTube channels that are recognized as music channels get a verified artist icon next to their channel name, this works in a similar way where popular YouTube channels get a verified icon next to their channel name.

Description

Motivation

We have decided to add bug reporting on the client using bugsnag, but we need to filter the reporting based on if the bug occurred on a music video or not. If we don't filter the bug reporting there would be too many notifications for bugs which are not in the project's scope.

To add filtering we need to decide if a video is a music video or not; since

@swapnilraj
swapnilraj / Privacy Policy
Created February 4, 2019 12:40
Gloinebot - Privacy Policy
Privacy Policy
Effective date: February 04, 2019
Gloinebot ("us", "we", or "our") operates the Gloinebot mobile application (the "Service").
This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data. Our Privacy Policy for Gloinebot is created with the help of the Free Privacy Policy website.