This file contains hidden or 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
| /** | |
| Pseudo : API key digest authentication rfc2617 | |
| Pre-requisite | |
| internal secret | |
| shared secret | |
| H = hash algorithm (SHA256) | |
| H1 = H + internal secret | |
| nc = counter | |
| Transaction flow |
This file contains hidden or 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
| /** | |
| * It requires *.min.css to be in same directory | |
| * we need to update the @media print part in css file to correct the color rendering issues when generating pdf files | |
| */ | |
| const fs = require('fs') | |
| const mustache = require('mustache') | |
| const path = require('path') | |
| const puppeteer = require('puppeteer') | |
| // dynamic cache for templates |
This file contains hidden or 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
| /** | |
| * {{#currency}}{{value}}{{/currency}} | |
| */ | |
| let formatter = { | |
| currency: () => (val, render) => { | |
| return render(val).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
| } | |
| } |
This file contains hidden or 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
| //require('./experimental')(__filename); // helper that throws when process.EXPERIMENTAL=false | |
| //const { debug } = require('./static'); // overriden debug function that includes user_id and transaction_id | |
| const debug = require('debug')('app'); | |
| /** | |
| * usage: | |
| * // eg. api/subscribers/email-notifications/index.js | |
| * const {debug} = require('../../commons/static'); | |
| * const events = require('../../commons/event_types'); | |
| * |
This file contains hidden or 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
| -- Disclaimer: not a standard rule. just a collection of ideas/experience while doing a fullstack development task -- | |
| identify the configurations that can affect the application restart, put those dynamic configuration in database. (eg. email config). | |
| create server.js (exports app and start function), and index.js (imports start function), so we can use the server.app for unit testing with supertest. | |
| identify the common functions and store them inside `commons` folder. | |
| create commons/errors to contain all the possible application errors we can throw, include the http status code. | |
| [frontend] | |
| eg. /commons | |
| '-- debouncer.dart | |
| '-- errors.dart |
This file contains hidden or 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
| /** Sample usage: | |
| * | |
| * let _encrypt, _decrypt, _createIV; | |
| * | |
| * repo.useEncryption = async (encryption) => { | |
| * if (!toString.call(_encrypt).match(/Function/) | |
| * && !toString.call(_decrypt).match(/Function/)) { | |
| * let config = encryption.configure([ | |
| * 'first_name', | |
| * 'last_name', |
This file contains hidden or 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
| @echo off | |
| REM this file is being called by apache via pipe in rotatelogs.exe | |
| REM adjustments to be made in apache httpd.conf (search for log_config_module) | |
| REM to rotate the logs every midnight | |
| REM CustomLog "|bin/rotatelogs.exe -p c:/<path to this dir>/rarlogs.bat -l c:/<path to client>/logs/access-%Y-%m-%d.log 86400" common | |
| REM rotate when reached 100Mb limit | |
| REM CustomLog "|bin/rotatelogs.exe -p c:/<path to this dir>/rarlogs.bat -l c:/<path to client>/logs/access-%Y-%m-%d-%H_%M.log 100M" common | |
| REM %1 new .log, %2 old .log | |
| set compress=1 |
This file contains hidden or 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 request = require('supertest'); | |
| const { app } = require('../server'); | |
| describe('Form input options', () => { | |
| it('GET /option/regions --> array public list regions', () => { | |
| return request(app) | |
| .get('/option/regions') | |
| .expect('Content-Type', /json/) | |
| .expect(200) |
This file contains hidden or 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 'dart:async'; | |
| class Debouncer { | |
| final Duration duration; | |
| Timer? debouncer; | |
| /// cancel previous action if recur within debounce duration | |
| Debouncer({ | |
| this.duration = const Duration(milliseconds: 200) | |
| }); |
This file contains hidden or 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 'package:flutter/material.dart'; | |
| import 'package:animations/animations.dart'; | |
| import 'package:sample/widgets/app_loading_indicator.dart'; | |
| import 'package:pointer_interceptor/pointer_interceptor.dart'; | |
| class ModalPrompt { | |
| static Future<R?> showProcessing<R>({ | |
| required context, | |
| required String message, | |
| required Future<R> Function() process, |
OlderNewer