Skip to content

Instantly share code, notes, and snippets.

View chathurawidanage's full-sized avatar
🏠
Working from home

Chathura Widanage chathurawidanage

🏠
Working from home
View GitHub Profile
@chathurawidanage
chathurawidanage / form
Created October 13, 2016 14:21
DHIS2 tracker capture custom form
<p>
<input id="ZzYYXq4fJie-GQY2lXrypjO-val" name="entryfield" title="GQY2lXrypjO - MCH Infant Weight (g) - undefined" value="[MCH Infant Weight (g)]" />
</p>
<p id="bmi-text">&nbsp;</p>
<script>
$(document).ready(function(){
function setColor(color){
$("p#bmi-text").css('background-color',color);
import java.util.concurrent.Semaphore;
/**
* @author Chathura Widanage
*/
public class Pizza {
private static volatile Semaphore pizzaPlate = new Semaphore(1);
private static volatile Semaphore delivery = new Semaphore(1);
private static volatile boolean orderInProgress = true;//order is in progress for first pizza
private static volatile int pizzas = 0;//no pizza initially
for(i=0;i<n;i++){
for(j=0;j<n;j++){
for(k=0;k<n;k++){
OUT[i][j]+=(A[i][k]*B[k][j]);
}
}
}
$.get("http://dhis.pgim.cmb.ac.lk/nss/api/organisationUnits.json?fields=[id,level,name]&filter=level:eq:3").then(function(data){
data.organisationUnits.forEach(function(ou){
$.get("http://dhis.pgim.cmb.ac.lk/nss/api/enrollments.json?ou="+ou.id+"&ouMode=DESCENDANTS&totalPages=true&skipPaging=true&programStatus=ACTIVE&program=MmGml1Gyb7K").then(function(data){
console.log(ou.name+":"+data.enrollments.length);
})
});
});
[default]
aws_access_key_id=<key>
aws_secret_access_key=<secret>
@chathurawidanage
chathurawidanage / reponse.xml
Created November 22, 2017 05:16
Yandex Trnslate API response
<?xml version="1.0" encoding="utf-8"?>
<Translation code="200" lang="en-fr">
<text>Translated Text</text>
</Translation>
@chathurawidanage
chathurawidanage / context.properties
Created November 22, 2017 06:03
Message Context
MessageContext.Message.Payload = <English News Item>
MessageContext.ScopeVariables.lan = en-si
@chathurawidanage
chathurawidanage / context2.properties
Created November 22, 2017 09:29
Message Context After Step 6
MessageContext.Message.Payload = <Translated News Item>
MessageContext.ScopeVariables.lan = en-si
MessageContext.ScopeVariables.text = <Translated News Item>
@chathurawidanage
chathurawidanage / publish.java
Last active November 22, 2017 10:14
Publishing Pseudocode
switch(messageContext.variables.lan){
case "en-si":
publishToSinhalaTopic(messageContext.message.payload);
break;
case "en-ta":
publishToTamilTopic(messageContext.message.payload);
break;
case "en-fr":
publishToFrenchTopic(messageContext.message.payload);
break;
let AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient();
exports.handler = function(event, context, callback) {
let now = new Date().getTime();
ddb.put({
TableName: 'contact_us',
Item: {
'name': event.name,
'email': event.email,
'phone': event.phone,