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 / 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 / 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;
})
}
@radiumrasheed
radiumrasheed / BitbucketPipelines2Firebase.md
Created October 1, 2018 11:51 — forked from DawidvanGraan/BitbucketPipelines2Firebase.md
Deploy your Angular 2 project with Bitbucket Pipelines to Firebase Hosting

Deploy your Angular 2 project with Bitbucket Pipelines to Firebase Hosting

Firebase

Please see the Firebase setup instruction to setup a project on Firebase.

Firebase CI Token

To run the firebase deploy command you need to obtain a login token from Firebase. To do so, run the firebase login:ci on your command line which will generate a token. Copy the generated token.

Environment Variables

Goto your project in Bitbucket, open the Settings and select Environment variables.

@radiumrasheed
radiumrasheed / file-size.pipe.ts
Created March 20, 2018 01:15 — forked from JonCatmull/file-size.pipe.ts
Angular2 + TypeScript file size Pipe/Filter. Convert bytes into largest possible unit. e.g. 1024 => 1 KB
import { Pipe, PipeTransform } from '@angular/core';
/*
* Convert bytes into largest possible unit.
* Takes an precision argument that defaults to 2.
* Usage:
* bytes | fileSize:precision
* Example:
* {{ 1024 | fileSize}}
* formats to: 1 KB
@radiumrasheed
radiumrasheed / gist:93cf887f6693658eb0b1d612ccbfcd34
Created October 3, 2017 08:54 — forked from resting/gist:3421760
AES128 encrypt/decrypt in PHP with base64
<?
function aes128Encrypt($key, $data) {
if(16 !== strlen($key)) $key = hash('MD5', $key, true);
$padding = 16 - (strlen($data) % 16);
$data .= str_repeat(chr($padding), $padding);
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, str_repeat("\0", 16)));
}
function aes128Decrypt($key, $data) {
@radiumrasheed
radiumrasheed / .env.travis
Created June 11, 2017 23:40 — forked from gilbitron/.env.travis
Laravel 5 Travis CI config
APP_ENV=testing
APP_KEY=SomeRandomString
DB_CONNECTION=testing
DB_TEST_USERNAME=root
DB_TEST_PASSWORD=
CACHE_DRIVER=array
SESSION_DRIVER=array
QUEUE_DRIVER=sync