Skip to content

Instantly share code, notes, and snippets.

View pasanbox's full-sized avatar

Pasan Wijesinghe pasanbox

View GitHub Profile
@pasanbox
pasanbox / alice_and_Strings.cpp
Created February 22, 2020 05:00
Alice and Strings
/*
HackerEarth
https://www.hackerearth.com/practice/algorithms/string-algorithm/basics-of-string-manipulation/practice-problems/algorithm/aliceandstrings-9da62aa7/
*/
#include <iostream>
/*
Recusrsively checks if string A can be converted to B by incrementing the prefixes:
FROM ubuntu:16.04
MAINTAINER pasanbox "pasanwijesinghe@gmail.com"
RUN apt-get update -y && \
apt-get install -y python-pip python-dev
# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt
Flask==1.0.2
Flask-HTTPAuth==3.2.4
Flask-RESTful==0.3.7
requests==2.21.0
Pasans-MacBook-Air:~ Pasan$ curl -u Alice:password -X GET http://127.0.0.1:5000/api/v1.0/isBad -d "name=Alfred"
{"isBad":"True"}
Pasans-MacBook-Air:~ Pasan$ curl -u Alice:password -X GET http://127.0.0.1:5000/api/v1.0/isBad -d "name=Radolf"
{"isBad":"False"}
#!flask/bin/python
from flask import Flask, jsonify
from flask_restful import reqparse
app = Flask(__name__)
badDwarves = ['Adolf', 'Joker', 'Bond']
@app.route('/api/v1.0/isBad', methods=['GET'])
def is_bad():
#!flask/bin/python
import requests
from flask import Flask, jsonify
from flask_httpauth import HTTPBasicAuth
from flask_restful import reqparse
auth = HTTPBasicAuth()
app = Flask(__name__)
badDwarves = ['Alfred', 'Sadam']
@pasanbox
pasanbox / employee_portal.sh
Created December 14, 2018 13:19
Cloning employee-portal
$ git clone https://github.com/wso2/product-vick.git
$ cd product-vick/samples/employee-portal/src/
$ tree .
.
├── hr
│   ├── Dockerfile
│   ├── hrservice.bal
├── portal
│   ├── employee
│   │   ├── Dockerfile
@pasanbox
pasanbox / table_join_example.bal
Last active October 12, 2018 16:58
Attempting to join tables retrieved from DB
import ballerina/io;
import ballerina/config;
import ballerina/log;
import ballerina/mysql;
import ballerina/sql;
endpoint mysql:Client databaseConnector {
host: "localhost",
port: 3306,
name: "github_issues",