Skip to content

Instantly share code, notes, and snippets.

@Madhuka
Madhuka / kubectl.csv
Last active June 14, 2023 06:05
Kubectl commands
Description Command
List pods with nodes info kubectl get pod -o wide
List everything kubectl get all --all-namespaces
Get all services kubectl get service --all-namespaces
Show nodes with labels kubectl get nodes --show-labels
Validate yaml file with dry run kubectl create --dry-run --validate -f pod-dummy.yaml
kubectl run shell command kubectl exec -it mytest -- ls -l /etc/hosts
Explain resource kubectl explain pods | kubectl explain svc
Get pods kubectl get pods
Check pod environment variables kubectl exec wso2apim-pod env
@Madhuka
Madhuka / Choose.xslt
Last active August 15, 2018 13:10
Basic XSLT
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no" />
<xsl:template match="/">
<message>
<test>Company</test>
<xsl:for-each select="catalog/cd">
<compactDisc>
<discTitle>
@Madhuka
Madhuka / JSONRequestForSMSAPI.json
Created June 25, 2018 08:52
Sample Json Request for SMS api
{
"host": "127.0.0.1",
"port": 2775,
"systemId": "wso2esb",
"password": "passesb",
"systemType": "UNKNOWN",
"addressTon": "UNKNOWN",
"addressNpi": "UNKNOWN",
"serviceType": "CMT",
"sourceAddressTon": "NETWORK_SPECIFIC",
@Madhuka
Madhuka / SMSAPI.xml
Created June 25, 2018 08:36
SMS-API for wso2 ESB
<api xmlns="http://ws.apache.org/ns/synapse" name="SMSAPI" context="/sms">
<resource methods="POST">
<inSequence>
<property name="OUT_ONLY" value="true"/>
<property name="host" expression="json-eval($.host)"/>
<property name="port" expression="json-eval($.port)"/>
<property name="systemId" expression="json-eval($.systemId)"/>
<property name="password" expression="json-eval($.password)"/>
<property name="systemType" expression="json-eval($.systemType)"/>
<property name="addressTon" expression="json-eval($.addressTon)"/>
<aspect name="BookServiceLifeCycle" class="org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle">
<configuration type="literal">
<lifecycle>
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="Acquisitions">
<state id="Acquisitions">
<datamodel>
<data name="checkItems">
<item name="Proposal Completed" forEvent="" />
<item name="Submit manuscript" forEvent="" />
<item name="Peer Review done" forEvent="" />
@Madhuka
Madhuka / book_rxt.xml
Last active March 21, 2018 06:28
This is WSO2 GREG RXT file for book schema
<?xml version="1.0"?>
<artifactType hasNamespace="true" iconSet="9" pluralLabel="MyBookLibrary" shortName="mybooklibrary"
singularLabel="MyBookLibrary" type="application/vnd.wso2-mmbrepo+xml">
<storagePath>/MyBookLibrary/@{details_name}</storagePath>
<nameAttribute>details_name</nameAttribute>
<namespaceAttribute>details_namespace</namespaceAttribute>
<lifecycle>BookServiceLifeCycle</lifecycle>
<ui>
<list>
<column name="Name">
@Madhuka
Madhuka / data.csv
Created July 19, 2015 14:26
sample data set
Country Name lat lng Altitude
United States New York City 40.7142691 -74.0059738 2.0
United States Los Angeles 34.0522342 -118.2436829 115.0
United States Chicago 41.8500330 -87.6500549 181.0
United States Houston 29.7632836 -95.3632736 15.0
United States Philadelphia 39.9523350 -75.1637878 8.0
United States Phoenix 33.4483771 -112.0740356 0.0
United States San Antonio 29.4241219 -98.4936295 196.0
United States San Diego 32.7153292 -117.1572571 26.0
United States Dallas 32.7830556 -96.8066635 137.0
from __future__ import division
from nltk.book import *
#Enter their names to find out about these texts
print "===Text Details==="
print text3
#Length of a text from start to finish, in terms of the words and punctuation symbols that appear.
print 'Length of Text: '+str(len(text3))
@Madhuka
Madhuka / affinity-propagation.py
Created April 29, 2015 09:17
Affinity Propagation clustering sample
import matplotlib.pyplot as plt
import numpy as np
from sklearn.cluster import AffinityPropagation
from sklearn import metrics
from sklearn.datasets.samples_generator import make_blobs
# generating sampl data
centers = [[5, 5], [0, 0], [1, 5],[5, -1]]
X, labels_true =make_blobs(n_samples=500, n_features=5, centers=centers, cluster_std=0.9, center_box=(1, 10.0), shuffle=True, random_state=0)
@Madhuka
Madhuka / DBSCAN
Created April 8, 2015 06:49
Running DBSCAN for generated data set
import matplotlib.pyplot as plt
import numpy as np
from sklearn.cluster import DBSCAN
from sklearn import metrics
from sklearn.datasets.samples_generator import make_blobs
# generating sampl data
centers = [[5, 5], [0, 0], [1, 5],[5, -1]]
X, labels_true =make_blobs(n_samples=500, n_features=5, centers=centers, cluster_std=0.9, center_box=(1, 10.0), shuffle=True, random_state=0)