Skip to content

Instantly share code, notes, and snippets.

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

Rasheed Rahman radiumrasheed

🏠
Working from home
View GitHub Profile
@radiumrasheed
radiumrasheed / Array.batch.js
Created February 3, 2022 18:33 — forked from seanmonstar/Array.batch.js
Similar to Array.each, but loops in batches, use setTimeout to allow the Browser thread to do other things, like respond to UI events and changes. Useful for really big arrays, or really intensive functions.
Array.implement('batch', function(callback, loopsPerBatch, delay, bind) {
if(!loopsPerBatch) loopsPerBatch = 10;
if(!delay) delay = 50;
if(callback) {
var loops = 0,
index = 0,
that = this;
function doLoops() {
loops = 0;
for (var length = that.length; (index < length) && loops < loopsPerBatch; index++) {
@radiumrasheed
radiumrasheed / ColumnFilter.js
Created January 9, 2022 18:57 — forked from srsandy/ColumnFilter.js
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);
@radiumrasheed
radiumrasheed / index.js
Created March 15, 2021 11:37
Comparing Left and Right Branch of a Complete Binary Tree
const solution = (arr) => {
if (!arr) return "";
if (arr.length === 0) return "";
const sum = (arr, idx) => {
if (idx - 1 < arr.length) {
if (arr[idx - 1] === -1) return 0;
return arr[idx - 1] + sum(arr, idx * 2) + sum(arr, idx * 2 + 1);
}
return 0;
};
@radiumrasheed
radiumrasheed / app-injector.ts
Created March 13, 2021 13:44
Simplify components with ts inheritance
import { Injector } from '@angular/core';
export class AppInjector {
private static injector: Injector;
static setInjector(injector: Injector) {
AppInjector.injector = injector;
}

Keybase proof

I hereby claim:

  • I am radiumrasheed on github.
  • I am radiumrasheed (https://keybase.io/radiumrasheed) on keybase.
  • I have a public key ASComMcs9ZUOEWPOBdqcsg_lyLQvtoL5LhufIinipke1hAo

To claim this, I am signing this object:

I build things with code

@radiumrasheed
radiumrasheed / angular-s3-redirect.xml
Last active February 26, 2020 17:36
angular s3 redirect rule
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>#/</ReplaceKeyPrefixWith>
<HttpRedirectCode>302</HttpRedirectCode>
</Redirect>
</RoutingRule>
@radiumrasheed
radiumrasheed / aws-s3-rename.coffee
Created November 5, 2019 20:46 — forked from roparz/aws-s3-rename.coffee
Rename object with Node.js AWS S3 (copy object then delete object) with promises
config = require 'config'
s3 = require 's3'
q = require 'q'
module.export = (oldKey, newKey) ->
defer = q.defer()
params =
# you need to set the s3 bucket in the CopySource key
CopySource: "#{ config.s3.bucket }/#{ oldKey }"
@radiumrasheed
radiumrasheed / logger.js
Created August 14, 2019 08:54
Integrate Winston Logger in Node Express App
'use strict';
const NODE_ENV = process.env.NODE_ENV || 'development';
const CloudWatchTransport = require('winston-aws-cloudwatch');
const Winston = require('winston');
let transport;
if (NODE_ENV === 'development') {
transport = new Winston.transports.Console({
format: Winston.format.combine(
@radiumrasheed
radiumrasheed / palindrome.js
Created June 17, 2019 12:16 — forked from NigelEarle/palindrome.js
Array of palindromes
const arr = ['mom', 'dad', 'abcde', 'racecar', 'momom'];
function namePalindrome(arr) {
return arr.filter((curr, idx, arr) => {
const splitArr = curr.split('');
const reversedString = splitArr.reduceRight((prev, curr) => ( prev + curr ), '');
if (curr === reversedString) return curr;
})
}