Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Mubasshir Pawle mubasshir

🎯
Focusing
View GitHub Profile
@mubasshir
mubasshir / inr-comma-separator.js
Last active Aug 3, 2020
Indian Rupee (INR) - comma separator
View inr-comma-separator.js
function formatNumber(numberToFormat) {
// converting to string
numberToFormat = numberToFormat + '' || '';
// to make it works for integer and floating as well
var numberAndDecimal = numberToFormat.split('.');
// decimals points only
var decimals = numberAndDecimal[1] || null;
// add commas
numberAndDecimal = numberAndDecimal[0].replace(/(\d)(?=(\d\d)+\d$)/g, "$1,");
// join
@mubasshir
mubasshir / paginate.dart
Created Feb 27, 2020
Dart Array Pagination
View paginate.dart
void main() {
List arr = [];
for (int i = 0; i < 100; i++) {
arr.add(i.toString());
}
int page = 1;
var startIndex = -1, endIndex = -1;
while (arr.length > 0 && endIndex != (arr.length - 1)) {
startIndex = (page - 1) * 10;
View multer-imager-storage.ts
import * as path from 'path';
import * as imager from 'multer-imager';
import * as dotenv from 'dotenv';
import * as fs from 'fs';
const ENV = process.env.NODE_ENV;
if (!ENV) {
const envFilePath = path.resolve(process.cwd(), 'env', !ENV ? '.env' : `.env.${ENV}`);
const envConfig = dotenv.parse(fs.readFileSync(envFilePath));
@mubasshir
mubasshir / highlight.ts
Created Apr 4, 2018
Angular 2 Search Highlight Pipe. Make searched char bold
View highlight.ts
import { PipeTransform, Pipe } from '@angular/core';
@Pipe({ name: 'highlight' })
export class HighlightPipe implements PipeTransform {
transform(text: string, search): string {
if (search && text) {
let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
pattern = pattern.split(' ').filter((t) => {
return t.length > 0;
}).join('|');
@mubasshir
mubasshir / 010_resource_files.js
Last active Apr 2, 2018 — forked from jimthedev/010_resource_files.js
Shell script to automatically copy icons and splash screens in Cordova 8.0 / Ionic Framework 3.20.0
View 010_resource_files.js
#!/usr/bin/env node
// this file lives at hooks/after_prepare/010_resource_files.js
//just replace your Project name with Eiosys
var filestocopy = [
{
"resources/android/icon/drawable-hdpi-icon.png":
"platforms/android/res/mipmap-hdpi/icon.png"
},
You can’t perform that action at this time.