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 / naira-amount-in-words.php
Created March 21, 2017 14:40
Collection of Functions to convert a Money Figure to Amount in Words (Currency - Naira and Kobo)
/**
* Amount in Words(Naira) Converter - Collection of PHP functions
* to convert a given Number into Naira Amount in Words
*
*/
function convertNumber($number) {
list($integer, $fraction) = explode(".", (string)$number);
$output = "";
@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
@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 / 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
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
@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 / 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 / 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 / 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 / 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>