Skip to content

Instantly share code, notes, and snippets.

Working from home

Kasun Thennakoon tmkasun

Working from home
View GitHub Profile
tmkasun /
Last active Aug 22, 2017
WSO2 API Manager get all subscriptions available for APIs created by given provider (user)
import requests, base64
configs = {
'credentials': {
'username': 'admin',
'password': 'admin',
'host': 'localhost',
'port': '9443',
'gateway_port': '8243',
tmkasun /
Last active Aug 10, 2017
javascript code snippets(live templates) for intellij

intellij javascript live templates

This is an improved version of this gist thsnks to ngryman I have added three new snippets creation of ES6 class, React Class Component and React Functional Component.

How install

  • Save below XML content to a file named custom_templates.xml.
  • Note: If you want to change the file name change the file name + group attribute in <templateSet group="custom_templates"> element as well.
  • Copy the custom_templates.xml file to ~IntelliJ IDEA{version}/config/templates
tmkasun /
Last active Oct 17, 2019
Setup APIM server and Run it with it's depending servers, Will only be useful until API manager product properly pack the dependencies in to final product. Till we get there ...
#! /usr/bin/env bash
# HOW TO USE: Put this file inside the directory where you would like to extract and run the product-APIM build file (.zip file)
# Change the below path variables accordingly *** NOTE: No trailing `/` slashes has been used
# This will only work with APIM 3.0.0 latest version with Carbon 4.x kernel. Addition to coping and unziping the pack,
# This script will only create symbolic links to the carbon-apimgt repository files.
tmkasun / in_sequence.xml
Created May 1, 2017
WSO2 APIM Dynamically Change Endpoint URL Synapse Sequence
View in_sequence.xml
<sequence xmlns="" name="WSO2AM--Ext--In">
<log level="custom">
<property name="TRACE" value="Inside InSequence"/>
<log level="full"/>
<property name="uri.var.sub_domain1" expression="get-property('system','environment.sub_domain1')"/>
<property name="uri.var.port" expression="get-property('system','environment.port')"/>
<log level="custom">
<property name="HOST " expression="$ctx:uri.var.sub_domain1"/>
<property name="PORT " expression="$ctx:uri.var.port"/>
tmkasun /
Last active Apr 19, 2017
Capture frames from Lepton camera using PyLepton and serialize the data and transmit it over web socket protocol
class ThermalDataHandler(WebSocketHandler):
clients = []
DEBUG = False
def __init__(self, application, request, **kwargs):
super(ThermalDataHandler, self).__init__(application, request, **kwargs)
if not ThermalDataHandler.DEBUG:
self.lepton = Lepton("/dev/spidev0.0")
self.mock_samples = MockData()
View sample_car_artifact.xml
<artifactType type="application/vnd.knnect-car+xml" shortName="car" singularLabel="Car" pluralLabel="Cars"
hasNamespace="false" iconSet="27">
<column name="name">
<data type="text" value="overview_name"/>
def create_asset(metadata, file_name):
credentials = '{username}:{password}'.format(username=conf['username'], password=conf['password'])
auth_value = b64encode(credentials.encode())
headers = {
'Authorization': '{type} {auth_value}'.format(type="Basic", auth_value=auth_value.decode()),
'Content-Type': 'application/json'
request_url = conf['artifact_endpoint']
response =, data=metadata, headers=headers, verify=False)
if not response.ok:
def main():
wb = openpyxl.load_workbook(conf['excel_file'])
name = wb.get_sheet_names()[0]
sheet = wb.get_sheet_by_name(name)
for row in range(2, sheet.max_row): # from 2 (assuming first row contains headers) to end of the rows
condition = sheet.cell(row=row, column=1).value
color = sheet.cell(row=row, column=2).value
year = sheet.cell(row=row, column=3).value
name = sheet.cell(row=row, column=4).value
description = sheet.cell(row=row, column=5).value
tmkasun /
Last active Jul 26, 2016
Sample user creation tool for WSO2 ES bulk user uploading
HEADER_STRING = "Username,Password,Claims,"
data_line = "{0},{0},http://{1}//claims/emailaddress={0}@{1},{2}\n"
file_string = HEADER_STRING + "\n"
domain = ""
role = ""
name_template = "user{}"
users_count = 51
with open(r'usernames.csv','w') as sample_file:
for index in range(1, users_count):
tmkasun / sample_users.csv
Last active Jul 26, 2016
WSO2 bulk users upload sample csv file
View sample_users.csv
UserName Password Claims
chris2 chris123
mical3 mical123
sharuk sharuk123
john john123
You can’t perform that action at this time.