Skip to content

Instantly share code, notes, and snippets.

View rajiff's full-sized avatar
🎯
Focusing

Basavaraj K N rajiff

🎯
Focusing
  • ThriveArch
  • Bangalore, INDIA
View GitHub Profile
package org.springframework.cloud.waves.server.stream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@rajiff
rajiff / app_auth_mongodb.md
Last active January 16, 2019 07:32
Application Authentication wit MongoDB

Hosting a MongoDB and creating accounts for application in it

  1. Docker Compose is only for creating root account in db admin, this is not the database for application

  2. Create Application specific accounts and set the authentication details

    2.1 Login to MongoDB using root credentials and use below syntax to create application specific account and the database

    2.2 Application should use its own DB and Credentials

Syntax for creating an account for application

@rajiff
rajiff / migrate_git_repo.sh
Last active May 11, 2022 13:45
Shell script to migrate a repo from one server to another along with branches & commit history
#!/bin/sh
# ensure correct number of arguments are passed
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <SOURCE Repo URL> <DIR to clone to> <TARGET Repo URL>" >&2
echo "example: /.migrate_git_repo.sh git@git.example.com:sampleuser/source_repo.git some_folder_name ssh://git@othergit.example.com:otheruser/destination_repo.git"
return
fi
srcRepo=$1
@rajiff
rajiff / index.js
Created April 17, 2018 04:10
NodeJS vanilla handling requests
const http = require('http');
const url = require('url');
// const querystring = require('querystring');
let server = http.createServer(function(req, res) {
let isMatched = false;
console.log("Got a new Request ", req.method, " => ", req.url);
// Query string parameter
let urlParts = url.parse(req.url, true);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="app"></div>
<script id="jsbin-javascript">
const express = require('express');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const graphqlHTTP = require('express-graphql');
const graphqlSchema = require('./graphqlSchema');
const {
graphql,
GraphQLSchema,
GraphQLObjectType,
const express = require('express');
const swaggerUI = require('swagger-ui-express');
const YAML = require('yamljs');
const swaggerDocument = YAML.load('./api/swagger/swagger.yaml');
let app = express();
// Mount the SwaggerUI Middleware, at your preferred mount path
let swaggerOptions = { explorer: false };
app.use('/api/v1/docs',
swaggerUI.serve,
swaggerUI.setup(swaggerDocument, swaggerOptions)
const swaggerDocument = require('yamljs').load('./api/swagger/swagger.yaml');
fs.writeFileSync('./api/swagger/swagger.json', JSON.stringify(swaggerDocument, null, ' '));
const swaggerDocument = require('yamljs').load('./api/swagger/swagger.yaml');
fs.writeFileSync('./api/swagger/swagger.json', JSON.stringify(swaggerDocument, null, ' '));
swagger: "2.0"
info:
version: "1.0.0"
title: SwaggerNodeJSDemo
# during dev, should point to your local machine
host: localhost:3000
# basePath prefixes all resource paths
basePath: /api/v1
schemes:
# tip: remove http to make production-grade