Skip to content

Instantly share code, notes, and snippets.

View sskanishk's full-sized avatar
🏠
Working from home

Kanish Malviya sskanishk

🏠
Working from home
View GitHub Profile
@sskanishk
sskanishk / index.js
Last active November 7, 2024 10:02
The code effectively serializes and deserializes data using Protobuf, ensuring data integrity and efficiency. It loads the Protobuf definition, verifies the payload, and converts it into a Protobuf message before encoding and decoding it. [protobuf sample code]
const protobuf = require('protobufjs');
// Load the generated Person class
const root = protobuf.loadSync('person.proto');
root.resolveAll();
// console.log("root ", root)
if (!root) {
console.error('Failed to load person.proto');
process.exit(1);
}
@sskanishk
sskanishk / highlight_text_in_pdf.py
Created October 30, 2024 17:01
Highlight specified text strings in a PDF using Python and PyMuPDF.
# Install Required Library
# pip install pymupdf
# --------------------------------------------
import fitz # PyMuPDF
def highlight_text_in_pdf(pdf_path, output_path, targets):
pdf_document = fitz.open(pdf_path)
@sskanishk
sskanishk / extract_youtube_captions.js
Created October 19, 2024 15:16
Extract youtube video caption from its API response!
// As per Oct 2024
// On click of caption icon on youtube player, a API (https://www.youtube.com/api/timedtext) will get trigger, check in network tab.
// Get the response and pass that payload in below javascript function
// **payload and API might get change in future.
function getCaption(payload) {
const concatenatedString = payload.events
.flatMap(event => event.segs ? event.segs.map(seg => seg.utf8) : [])
.join('');
@sskanishk
sskanishk / CopyToClipbaord.js
Last active May 27, 2021 09:02
Code Snippet Code to Clipboard button functionality on code snippet.
// it is written for below structure
<pre>
<code>
----some----code----
</code>
<pre>
function CopyToClipboard(params) {
@sskanishk
sskanishk / Clone.js
Created February 5, 2021 21:38
Code 1) Deep Clone
const obj = {
name: "Paddy",
address: {
town: "Lerum",
country: "Sweden"
}
}
function deepClone(obj) {
return {...obj}
@sskanishk
sskanishk / Readme.md
Last active September 7, 2022 02:39
Setup MySQL in AWS Cloud9

Open EC2 Cloud9

$ sudo service mysqld start

$ /usr/libexec/mysql55/mysql_secure_installation

comment - if first time Set root password? [Y/n] $ Y

Remove anonymous users? [Y/n] $ Y

@sskanishk
sskanishk / gist:badbf24b1b3086cf70f0cd60020ca4b6
Last active July 6, 2019 07:07
Tables and plots are the most common outputs when doing data analysis, but Jupyter notebooks can render many more types of outputs such as sound, animation, video, etc. Yes, almost anything that can be shown in a modern web browser. This also makes it possible to include interactive widgets directly in the notebook! For example, this (slightly c…
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.