Skip to content

Instantly share code, notes, and snippets.

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

Sagar sagar290

🏠
Working from home
View GitHub Profile
@sagar290
sagar290 / get_row_by_valye.gs
Created April 22, 2023 17:14
App script get sheet row number by specific value
function getRowNumberByValue() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
const searchValue = 'value to search for';
const dataRange = sheet.getRange('A:A');
const values = dataRange.getValues();
for (let i = 0; i < values.length; i++) {
if (values[i][0] === searchValue) {
const rowNumber = i + 1;
Logger.log(`Found "${searchValue}" at row ${rowNumber}`);
@sagar290
sagar290 / golang-errors-stack-line.go
Created March 26, 2023 05:28 — forked from rms1000watt/golang-errors-stack-line.go
Golang Errors Stacktrace and Line Number
// https://godoc.org/github.com/pkg/errors#Frame.Format
package main
import (
"fmt"
"github.com/pkg/errors"
)
@sagar290
sagar290 / progress.py
Created February 7, 2023 18:25
progress bar in terminal by python
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required : total iterations (Int)
prefix - Optional : prefix string (Str)
suffix - Optional : suffix string (Str)
decimals - Optional : positive number of decimals in percent complete (Int)
length - Optional : character length of bar (Int)
@sagar290
sagar290 / satori.js
Created November 27, 2022 18:23
Satori pdf generation sample code
console.log('Hello World');
import satori from 'satori'
import { SatoriOptions } from 'satori';
import * as fs from 'fs';
import SVGtoPDF from 'svg-to-pdfkit';
import PDFKit from 'pdfkit';
@sagar290
sagar290 / .php-cs-fixer.php
Created November 17, 2022 13:25 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Coding Style Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space',
@sagar290
sagar290 / lengthOfLongestSubstring.go
Created October 1, 2022 15:34
Length of Longest Substring
// solution 1
func lengthOfLongestSubstring(s string) int {
length := len(s)
var result []string
// fmt.Println(s[1:4])
@sagar290
sagar290 / main.go
Created September 3, 2022 15:19
Hash table, insert, search, delete
package main
import "fmt"
const ArraySize = 7
type HashTable struct {
array [ArraySize]*bucket
}
@sagar290
sagar290 / main.go
Created September 3, 2022 13:41
Linked List in go
package main
import "fmt"
type node struct {
data int
next *node
}
type linkedList struct {
import redis
source = redis.Redis(host='localhost', port=63790, db=1)
#destination = redis.Redis(host='localhost', port=63790, db=5)
keys = source.keys('auth-service:*')
print("key,vallue,ttl")
for key in keys:
#destination.set(key, source.get(key), source.ttl(key))
import { HttpService } from '@nestjs/axios';
import { AxiosRequestHeaders } from 'axios';
import { Injectable } from '@nestjs/common';
import { firstValueFrom } from 'rxjs';
@Injectable()
export class BaseHttpService {
public baseUrl: string;
public secretKey: string;
private headers: AxiosRequestHeaders = {};