Skip to content

Instantly share code, notes, and snippets.

View harshadura's full-sized avatar

Harsha Siriwardena harshadura

View GitHub Profile
for (final String groupId: memberList){
Query searchQuery3 = database.child("userGroups").child(groupId);
ValueEventListener valueEventListener = new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
System.out.println("**i am here");
final UserGroup userGroup = dataSnapshot.getValue(UserGroup.class);
final List<String> usersList = userGroup.getUsersList();
/**
* Copyright Google Inc. All Rights Reserved.
* <p/>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
@RequestMapping("/authorize")
public String authorize(@RequestParam(value="username", defaultValue="username") String username,
@RequestParam(value="password", defaultValue="password") String password) {
FirebaseHandler firebaseHandler = new FirebaseHandler(mFirebaseDatabaseReference, new FirebaseHandler.FirebaseServiceListener() {
@Override
public void onSuccessResponseReceived(Object response) {
return ; // << error
}
@harshadura
harshadura / StringOrder.java
Created February 17, 2016 04:07
Write a function f(a, b) which takes two character string arguments and returns a string containing only the characters found in both strings in the order of a. Write a version which is order N-squared and one which is order N.
/**
* Created by harshadura on 2/17/16.
*/
public class StringOrder {
public static void main(String args[]) {
String inputA = "harsha";
String inputB = "sanjeewa";
System.out.println(orderByNSq(inputA.toCharArray(), inputB.toCharArray()));
System.out.println(orderByN(inputA.toCharArray(), inputB.toCharArray()));
@harshadura
harshadura / GenerateRandom.java
Created February 17, 2016 03:25
Q) Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7. - Java solution
/**
* Created by harshadura on 2/17/16.
*/
public class GenerateRandom {
private static int[][] range7Array = new int[][]{
{1, 2, 3, 4, 5},
{6, 7, 1, 2, 3},
{4, 5, 6, 7, 1},
{2, 3, 4, 5, 6},
@harshadura
harshadura / SharingBaseActivity.java
Created January 30, 2015 08:30
Facebook opengraph test
/**
* @author Harsha Siriwardena
*
*/
public class SharingBaseActivity extends Activity {
public Spinner sharingSpinner;
String SD_CARD_PATH = null;
package lancerscan;
import jd2xx.JD2XX;
public class Test {
public static void main(String[] args) throws Exception {
JD2XX jd = new JD2XX();
jd.open(0);
@harshadura
harshadura / gist:8155284
Last active January 1, 2016 13:59
subsc api im
// Check for subscription
try {
SubscriptionStatusResponse subscriptionStatusResponse = getSubscriptionStatus(phoneNumber);
String statusCode2 = subscriptionStatusResponse.getStatusCode();
String statusDetails2 = subscriptionStatusResponse.getStatusDetail();
if (statusCode2.equals("S1000")) {
String infoMsg = "Subscribed user!";
LOGGER.info(infoMsg);
flagSubs = true;
@harshadura
harshadura / gist:7496479
Last active December 28, 2015 11:49
ideamart CASS java - direct Debit- working sample code
package org.durapix.sms.controller;
import java.util.*;
import hms.kite.samples.api.StatusCodes;
import hms.kite.samples.api.caas.ChargingRequestSender;
import hms.kite.samples.api.caas.messages.DirectDebitRequest;
import hms.kite.samples.api.caas.messages.DirectDebitResponse;
import hms.kite.samples.api.sms.MoSmsListener;
import hms.kite.samples.api.sms.SmsRequestSender;
import hms.kite.samples.api.sms.messages.MoSmsReq;
ERROR - XformsUtil.reportDataUploadError(608) |2013-09-06 20:21:53,066| 'Encounter: [(no ID) Sat Sep 07 00:00:00 UTC 2013 patient_narratives null 2 Test1 num Obs: [obs id is null, obs id is null, obs id is null, obs id is null, obs id is null, obs id is null, obs id is null, obs id is null] num Orders: 0 ]' failed to validate with reason: encounterDatetime: The encounter datetime should be before the current date.
org.openmrs.api.APIException: 'Encounter: [(no ID) Sat Sep 07 00:00:00 UTC 2013 patient_narratives null 2 Test1 num Obs: [obs id is null, obs id is null, obs id is null, obs id is null, obs id is null, obs id is null, obs id is null, obs id is null] num Orders: 0 ]' failed to validate with reason: encounterDatetime: The encounter datetime should be before the current date.
at org.openmrs.validator.ValidateUtil.validate(ValidateUtil.java:85)
at org.openmrs.aop.RequiredDataAdvice.before(RequiredDataAdvice.java:136)
at org.springframework.aop.framework.adapter.MethodBeforeAdvice