Skip to content

Instantly share code, notes, and snippets.

View tmkasun's full-sized avatar
🕶️

Kasun Thennakoon tmkasun

🕶️
View GitHub Profile
@tmkasun
tmkasun / gadget.xml
Last active June 13, 2016 08:54
Sample WSO2 Registry eXTention (RXT) File
<?xml version="1.0"?>
<artifactType type="application/vnd.wso2-gadget+xml" shortName="gadget" singularLabel="Gadget" pluralLabel="Gadgets"
hasNamespace="false" iconSet="10">
<storagePath>/gadgets/@{overview_name}/@{overview_version}</storagePath>
<nameAttribute>overview_name</nameAttribute>
<ui>
<list>
<column name="Name">
<data type="path" value="overview_name" href="@{storagePath}"/>
</column>
@tmkasun
tmkasun / solr_sample.json
Last active June 14, 2016 11:55
WSO2 Sample solr query for sorting assets by overview_name
{
"params": {
"q": "*TO*",
"indent": "true",
"fq": [
"tenantId:\\-1234",
"allowedRoles:(internal/everyone OR admin)",
"mediaType_s:application/vnd.wso2-gadget+xml"
],
"sort": "overview_name_s asc",
@tmkasun
tmkasun / sort.js
Last active June 14, 2016 16:59
wso2 ES sample sort attributes configuration
sorting: {
attributes: [
{name: "overview_name", label: "Name"},
{name: "overview_version", label: "Version"},
{name: "overview_provider", label: "Provider"},
{name: "createdDate", label: "Date/Time"}]
}
@tmkasun
tmkasun / sample_users.csv
Last active July 26, 2016 06:13
WSO2 bulk users upload sample csv file
UserName Password Claims
chris2 chris123 http://wso2.org/claims/emailaddress=dracusds123@gmail.com http://wso2.org/claims/role=admin
mical3 mical123 http://wso2.org/claims/emailaddress=dracusds123@gmail.com http://wso2.org/claims/role=admin
sharuk sharuk123 http://wso2.org/claims/emailaddress=dracusds123@gmail.com http://wso2.org/claims/role=admin
john john123 http://wso2.org/claims/emailaddress=dracusds123@gmail.com http://wso2.org/claims/role=admin
@tmkasun
tmkasun / create_users.py
Last active July 26, 2016 06:20
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 = "knnect.com"
role = "http://wso2.org/claims/role=admin"
name_template = "user{}"
users_count = 51
with open(r'usernames.csv','w') as sample_file:
for index in range(1, users_count):
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
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 = requests.post(request_url, data=metadata, headers=headers, verify=False)
if not response.ok:
<artifactType type="application/vnd.knnect-car+xml" shortName="car" singularLabel="Car" pluralLabel="Cars"
hasNamespace="false" iconSet="27">
<storagePath>/trunk/car/@{overview_name}</storagePath>
<nameAttribute>overview_name</nameAttribute>
<ui>
<list>
<column name="name">
<data type="text" value="overview_name"/>
</column>
@tmkasun
tmkasun / lepton_data_service.py
Last active April 19, 2017 13:55
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.lepton.__enter__()
self.mock_samples = MockData()
@tmkasun
tmkasun / in_sequence.xml
Created May 1, 2017 13:38
WSO2 APIM Dynamically Change Endpoint URL Synapse Sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<log level="custom">
<property name="TRACE" value="Inside InSequence"/>
</log>
<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"/>