Skip to content

Instantly share code, notes, and snippets.

View KPChakravarthy's full-sized avatar

Krishna Prasad C KPChakravarthy

  • Bangalore
View GitHub Profile
@KPChakravarthy
KPChakravarthy / chat.component.ts
Last active November 9, 2020 09:50
Angular 7 + Firebase Support Chat Snippets
import { Component, OnInit } from '@angular/core';
import { ChatService } from './chat.service';
@Component({
selector: 'app-chat',
templateUrl: './chat.component.html',
styleUrls: ['./chat.component.scss']
})
export class ChatComponent implements OnInit {
messagesList: any;
@KPChakravarthy
KPChakravarthy / excelFileRead.js
Last active August 23, 2019 07:21
NodeJS Postgresql Bulk upsert.
// import XlsxStreamReader - it is an npm package ==== https://www.npmjs.com/package/xlsx-stream-reader
function readXlsx(file, headers) {
return new Promise((resolve, reject) => {
let resp_row = [];
var workBookReader = new XlsxStreamReader();
workBookReader.on('error', function (error) {
throw error;
});
workBookReader.on('sharedStrings', function () {
@KPChakravarthy
KPChakravarthy / angular.svg
Last active March 8, 2020 09:01
stack logos
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function selectFile(event) {
let blobURL = window.URL.createObjectURL(event.target.files[0])
// Do what you will with the blob
};
chrome.tabs.create(
{
url: url,
},
(tab) => {
chrome.tabs.executeScript(
tab.id,
{
code: `var blobURL = "${blobURL}"; console.log("1:::")`,
},
function sendFile() {
var x = new XMLHttpRequest();
x.open("GET", blobURL);
x.responseType = "blob";
x.onload = function () {
var url = URL.createObjectURL(x.response);
localStorage.setItem("fileToProcess", url);
window.onload = function () {
document.getElementById("fetchImageFromBlob").click();
};
@KPChakravarthy
KPChakravarthy / htmldiff.js
Created August 10, 2020 04:41
Diff between 2 HTML documents
var Match,
calculate_operations,
consecutive_where,
create_index,
diff,
find_match,
find_matching_blocks,
html_to_tokens,
is_end_of_tag,
is_start_of_tag,
@KPChakravarthy
KPChakravarthy / pre-commit
Created September 9, 2022 04:56 — forked from swateek/pre-commit
PreCommit Hook - Convert Tab to Spaces for Golang Files
#!/bin/bash
# Print an introduction line in cyan
printf "\033[0;36mPre-commit hook - For Checking Tabs in Golang Files...\033[0m \n"
# Grab feed of staged files
files=$(git diff --name-only --cached -- "*.go")
numfiles=$( printf '%s' "$files" | grep -c '^' )
if [ $numfiles -eq 0 ]
@KPChakravarthy
KPChakravarthy / vscode-mods.json
Created September 16, 2022 05:35 — forked from impmja/vscode-mods.json
Visual Studio Code: Mods
{
"recommendations": [
"CoenraadS.bracket-pair-colorizer",
"mikestead.dotenv",
"oderwat.indent-rainbow",
"robertohuertasm.vscode-icons",
"esbenp.prettier-vscode",
"jsynowiec.vscode-insertdatestring",
"alefragnani.project-manager",
"codezombiech.gitignore",