Monthly Archives: September 2016

Using Threads Java

package webdrivertest; public class Threadertest implements Runnable{ Thread t; public static void main(String[] args) { Threadertest t=new Threadertest(); } Threadertest() { t=new Thread(this,“Demo Thread”); System.out.println(“Starting demo thread”); t.start(); } @Override public void run() { for(int i=0;i<5;i++) { try { Thread.sleep(3000); … Continue reading

Posted in Uncategorized | Leave a comment

Dicttionaries-Python

”’ Created on Sep 25, 2016 @author: ashishsharda ”’ groceris={‘Vegetables’:‘Cabbage’,‘Fruits’:‘Banana’} for k,v in groceris.items():     print k,v     print groceris[‘Vegetables’]

Posted in Uncategorized | Leave a comment

Check for Duplicates -Python

”’ Created on Sep 25, 2016 @author: ashishsharda ”’ #Sets in a but not in b a=set(‘ashish‘) b=set(‘abhay‘) print a-b #Print Letters in both a and break print a&b #Print letters in either a or b print a|b #Print letters … Continue reading

Posted in Uncategorized | Leave a comment

List Operations -python

”’ Created on Sep 25, 2016 @author: ashishsharda ”’ list11=[5,2,8,1] print list11 print “First element in list is “,list11[0] print “Length of list is “,len(list11) print ” Max element of list”,max(list11) print “Min element of list”,min(list11) list11.reverse() print “Reverse list”,list11 … Continue reading

Posted in Python, Uncategorized | Tagged | Leave a comment

Mesos on Mac

Download Homebrew: (1)ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)” (2)Step II:brew update (3)brew install mesos (4)Start Your Mesos Cluster /usr/local/sbin/mesos-master –registry=in_memory –ip=127.0.0.1 (5)Start Mesos Slave: sudo /usr/local/sbin/mesos-slave –master=127.0.0.1:5050

Posted in Uncategorized | Leave a comment

Stack implementation in Java

import org.testng.annotations.Test; /** * Test Stack * @author ashishsharda * */ public class StackerTest { int[] st=new int[10]; int tos=-1; /** * Push an element to top of stack. * @param value */ publicvoid push(int value) { if (tos==9) { … Continue reading

Posted in Java | Tagged | Leave a comment

Pass a list to Vector and sort it

@Test public void testVector() { LinkedList<Integer>list =new LinkedList<Integer>(); list.add(30); list.add(20); list.add(10); list.add(40); Collections.addAll(list); Collections.sort(list); Vector<Integer> vector=new Vector<Integer>(list); for(Integer i:vector) System.out.println(i); }

Posted in Java, Uncategorized | Tagged , | Leave a comment