Skip to content

Instantly share code, notes, and snippets.

View srsandy's full-sized avatar
👨‍💻
Learning everyday.

Sandeep「 Flame 」 srsandy

👨‍💻
Learning everyday.
  • Delhi IND
View GitHub Profile
@srsandy
srsandy / Polyfills.js
Created September 10, 2022 11:27
Polyfills
// map
Array.prototype.myMap = function (cb) {
const results = [];
for (let i = 0; i < this.length; i++) {
results[i] = cb(this[i], i, this);
}
return results;
};
// filter
function myFunction() {
// var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// var activeSheet = activeSpreadsheet.getActiveSheet();
var ss = SpreadsheetApp.getActive();
var allsheets = ss.getSheets();
for(var s in allsheets){
var targetSheet = allsheets[s];
SpreadsheetApp.setActiveSheet(targetSheet);
var lrow = targetSheet.getLastRow();
var lcol = targetSheet.getLastColumn();
@srsandy
srsandy / ColumnFilter.js
Last active January 11, 2024 06:54
React Table Server side Pagination and Filtering
import "regenerator-runtime/runtime";
import { useState } from "react";
import { useAsyncDebounce } from "react-table";
const ColumnFilter = ({ column }) => {
const { filterValue, setFilter } = column;
const [value, setValue] = useState(filterValue);
const onChange = useAsyncDebounce((value) => {
setFilter(value || undefined);
}, 300);
@srsandy
srsandy / MyLinkedList.cs
Created August 4, 2021 20:56
C# generic linked list implementation. Contains add, remove and sort (bubble sort).
using System;
using System.Collections.Generic;
using System.Text;
namespace CSharpWork
{
public class MyLinkedList<T> where T: IComparable
{
class Node<G>
@srsandy
srsandy / this.js
Created February 23, 2021 10:14
All `this` variations
// GLOBAL
console.log(this); //--> window
// FUNCTION
function discoverThis() {
console.log(this); //--> window
}
discoverThis();
// OBJECT
@srsandy
srsandy / uninstallAndroid.sh
Last active February 23, 2021 10:18
Remove everything related to Android and Android Studios on Linux/Mac
#!/bin/bash
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm -Rf ~/Library/Preferences/com.google.android.*
rm -Rf ~/Library/Preferences/com.android.*
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
rm -Rf ~/Library/Caches/AndroidStudio*
rm -Rf ~/.AndroidStudio*
@srsandy
srsandy / put-object-on-aws-s3.php
Created January 28, 2020 13:06 — forked from keithweaver/put-object-on-aws-s3.php
Upload an image/object to an AWS S3 Bucket using PHP
<?php
// Installed the need packages with Composer by running:
// $ composer require aws/aws-sdk-php
$filePath = "https://example.com/test.png";
require 'vendor/autoload.php';
$bucketName = 'YOUR_BUCKET_NAME';
$filePath = './YOUR_FILE_NAME.png';
@srsandy
srsandy / System Design.md
Created December 30, 2019 16:19 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@srsandy
srsandy / crypto.js
Created November 16, 2019 17:24
Encrypt and Decrypt emails
const crypto = require('crypto');
const algorithm = 'aes-192-cbc';
const password = '3zTvzr3p67VC61jmV54rIYu1545x4TlY';
const key = crypto.scryptSync(password, 'salt', 24);
const iv = Buffer.alloc(16, 0);
function encrypt(text) {
const cipher = crypto.createCipheriv(algorithm, key, iv)
@srsandy
srsandy / .bash_aliases
Created August 10, 2019 13:09 — forked from vratiu/.bash_aliases
Git shell coloring
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset