Skip to content

Instantly share code, notes, and snippets.

View hossain-khan's full-sized avatar
🙈
Just do it!

Hossain Khan hossain-khan

🙈
Just do it!
View GitHub Profile
@hossain-khan
hossain-khan / api-spec_validation_test.sh
Last active August 21, 2016 14:31
Shell script that uses shUnit2 for validating OpenAPI specification file. This file is taken from https://github.com/amardeshbd/medium-api-specification and **modified** for embedding on web, see github project for details.
#!/bin/sh
# NOTE: This file is modified version taken from:
# https://github.com/amardeshbd/medium-api-specification/blob/master/api-spec_validation_test.sh
# Tests the swagger specificaton using online service
testOpenApiSpecValidity() {
expectedOutput="{}"
expectedOutputSize=${#expectedOutput}
@hossain-khan
hossain-khan / travis-ci-build.yml
Last active August 28, 2016 14:28
Travis-CI build config file used for validating OpenAPI specification file. This file is taken from https://github.com/amardeshbd/medium-api-specification and **modified** for embedding on web, see github project for details.
language: bash
before_script:
# Load the shUnit2 for running shell-script unit test
- curl -L "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/shunit2/shunit2-2.1.6.tgz" | tar zx
script:
# Get proper branch name based on http://graysonkoonce.com/getting-the-current-branch-name-during-a-pull-request-in-travis-ci/
- export PR=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo `curl -s $PR | jq -r .head.ref`; fi)
@hossain-khan
hossain-khan / MockSharedPreference.java
Last active March 13, 2020 18:13
Android Mock Shared Preference for unit testing. (NOTE: The intention here is to avoid mocking lots of API related to `SharedPreferences`, as outcome from interacting with `SharedPreferences` is not relevant in the unit test.). Please comment if there is a cleaner way of doing this.
import android.content.SharedPreferences;
import android.support.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
productFlavors {
dev {
// To avoid using legacy multidex, set minSdkVersion to 21 or higher.
minSdkVersion 21
// The following configuration limits the "dev" flavor to using
// English string resources and xxhdpi screen-density resources.
resConfigs "en", "xxxhdpi"
@hossain-khan
hossain-khan / firebase-list.sh
Created March 13, 2019 02:58
Firebase list projects
firebase list
@hossain-khan
hossain-khan / firebase-init.sh
Created March 13, 2019 02:59
Firebase init
firebase init
@hossain-khan
hossain-khan / firebase-use-project.sh
Created March 13, 2019 03:00
Firebase User Project ID
firebase use --add your-project-id-23d6x
@hossain-khan
hossain-khan / update-npm.sh
Created March 13, 2019 03:15
Update npm modules
cd functions
npm install
cd ..
@hossain-khan
hossain-khan / express-and-firebase.js
Created March 13, 2019 03:20
Firebase and express barebone.
'use strict';
// [START import]
const functions = require('firebase-functions');
const express = require('express');
const app = express();
// [END import]
// [START middleware]
const cors = require('cors')({origin: true});
@hossain-khan
hossain-khan / express-simple-api.js
Created March 13, 2019 03:24
Express JS API Example
/**
* Say hello API
* Try: https://mock-apis-server.firebaseapp.com/say/hello
*/
app.get('/say/hello', (req, res) => {
// Return success response
return res.status(200).json({"message":"Hello there... Welcome to mock server."});
});
/* [END `/say/hello` ] - must be added before `exports.api = ...` */