This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('|'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class uploadToS3 { | |
async downloadRemoteFile(url: string): Promise<any> { | |
return new Promise((resolve, reject) => { | |
// make request | |
// import axios | |
axios({ | |
url: url, | |
method: 'GET', | |
responseType: 'arraybuffer', | |
decompress: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const posts = [{ id: 1, title: 'Post 1' }, { id: 2, title: 'Post 2' }, { id: 3, title: 'Post 3' }, { id: 4, title: 'Post 4' }]; | |
const polls = [{ id: 1, question: 'Poll 1' }, { id: 2, question: 'Poll 2' }]; | |
// get minimum length of both arrays | |
const minLength = Math.min(posts.length, polls.length); | |
// create | |
let postsAndPolls:any = []; | |
// loop through the array and fill it with the posts and polls | |
for (let i = 0; i < minLength; i++) { | |
// push ith post and ith poll to the array | |
postsAndPolls.push(posts[i], polls[i]); |