Skip to content

Instantly share code, notes, and snippets.

@asiletto
Created March 16, 2014 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asiletto/9584882 to your computer and use it in GitHub Desktop.
Save asiletto/9584882 to your computer and use it in GitHub Desktop.
test gliderbot per app meteor Giuliano
package test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import me.kutrumbos.DdpClient;
import me.kutrumbos.examples.SimpleDdpClientObserver;
/*
* jar needed:
* - java-ddp-client.jar: https://github.com/kutrumbo/java-ddp-client
* - gson-2.2.4.jar: https://code.google.com/p/google-gson/downloads/detail?name=google-gson-2.2.4-release.zip&can=2&q=
*/
public class DisegnaAlianti {
static String HOST = "ddp--7287-my-paint-your-paint.meteor.com";
static Integer PORT = 80;
static String USER = "gliderBot";
static Boolean debug = true;
public static void main(String[] args) throws Exception {
List<String[]> moves = getMoves();
List<String[]> reset = getMovesReset();
DdpClient client = new DdpClient(HOST, PORT);
if(debug)
client.addObserver(new SimpleDdpClientObserver());
client.connect();
for (String[] pixels : reset)
draw(client, pixels[0], pixels[1]);
while(true){
for (String[] pixels : moves)
if(pixels.length==0)
Thread.sleep(1000);
else
draw(client, pixels[0], pixels[1]);
for (String[] pixels : reset)
draw(client, pixels[0], pixels[1]);
}
}
private static List<String[]> getMoves() {
List<String[]> ret = new ArrayList<String[]>();
ret.add(new String[]{"9kSFupjGugxstQPBc","#ffffff"});
ret.add(new String[]{"jZD3w92ZJgccHN6XW","#ffffff"});
ret.add(new String[]{"7aFPLzfrSw4ZsJqhY","#ffffff"});
ret.add(new String[]{"5FKw4ydT67nH28Zsw","#ffffff"});
ret.add(new String[]{"bibT9WLHWvnSLKxJb","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"5FKw4ydT67nH28Zsw","#000000"});
ret.add(new String[]{"bibT9WLHWvnSLKxJb","#000000"});
ret.add(new String[]{"kohuYLGN3NJFAv8hp","#ffffff"});
ret.add(new String[]{"Rqy3C3W84ebuXmLF2","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"Rqy3C3W84ebuXmLF2","#000000"});
ret.add(new String[]{"7aFPLzfrSw4ZsJqhY","#000000"});
ret.add(new String[]{"r6bzb2ZKdrvK8mcse","#ffffff"});
ret.add(new String[]{"5FKw4ydT67nH28Zsw","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"5FKw4ydT67nH28Zsw","#000000"});
ret.add(new String[]{"9kSFupjGugxstQPBc","#000000"});
ret.add(new String[]{"3m52FqtjBzxfpn6kY","#ffffff"});
ret.add(new String[]{"uj868d6gM4PXQDCGq","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"jZD3w92ZJgccHN6XW","#000000"});
ret.add(new String[]{"3m52FqtjBzxfpn6kY","#000000"});
ret.add(new String[]{"33Yn3n2DQhZxy2FHx","#ffffff"});
ret.add(new String[]{"9kSFupjGugxstQPBc","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"kohuYLGN3NJFAv8hp","#000000"});
ret.add(new String[]{"9kSFupjGugxstQPBc","#000000"});
ret.add(new String[]{"8TQy7kH4AszpKX7DC","#ffffff"});
ret.add(new String[]{"7aFPLzfrSw4ZsJqhY","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"7aFPLzfrSw4ZsJqhY","#000000"});
ret.add(new String[]{"r6bzb2ZKdrvK8mcse","#000000"});
ret.add(new String[]{"z5arsNe8ZwKzHsith","#ffffff"});
ret.add(new String[]{"kohuYLGN3NJFAv8hp","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"uj868d6gM4PXQDCGq","#000000"});
ret.add(new String[]{"kohuYLGN3NJFAv8hp","#000000"});
ret.add(new String[]{"TfL4ktfYh7Qe93LpR","#ffffff"});
ret.add(new String[]{"jZD3w92ZJgccHN6XW","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"33Yn3n2DQhZxy2FHx","#000000"});
ret.add(new String[]{"jZD3w92ZJgccHN6XW","#000000"});
ret.add(new String[]{"t57MBG5AZEinmGC6E","#ffffff"});
ret.add(new String[]{"uj868d6gM4PXQDCGq","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"8TQy7kH4AszpKX7DC","#000000"});
ret.add(new String[]{"uj868d6gM4PXQDCGq","#000000"});
ret.add(new String[]{"r6bzb2ZKdrvK8mcse","#ffffff"});
ret.add(new String[]{"pcAWguT7ae9AsRAni","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"z5arsNe8ZwKzHsith","#000000"});
ret.add(new String[]{"r6bzb2ZKdrvK8mcse","#000000"});
ret.add(new String[]{"TsvPKYMGE5RRbn9NM","#000000"});
ret.add(new String[]{"8TQy7kH4AszpKX7DC","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"8TQy7kH4AszpKX7DC","#000000"});
ret.add(new String[]{"TfL4ktfYh7Qe93LpR","#000000"});
ret.add(new String[]{"33Yn3n2DQhZxy2FHx","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"t57MBG5AZEinmGC6E","#000000"});
ret.add(new String[]{"33Yn3n2DQhZxy2FHx","#000000"});
ret.add(new String[]{"TfL4ktfYh7Qe93LpR","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"pcAWguT7ae9AsRAni","#000000"});
ret.add(new String[]{"TfL4ktfYh7Qe93LpR","#000000"});
ret.add(new String[]{"z5arsNe8ZwKzHsith","#ffffff"});
ret.add(new String[]{"fHv5dPBjBFqA6F5hq","#ffffff"});
ret.add(new String[]{});
ret.add(new String[]{"TsvPKYMGE5RRbn9NM","#000000"});
ret.add(new String[]{"z5arsNe8ZwKzHsith","#000000"});
ret.add(new String[]{"pcAWguT7ae9AsRAni","#ffffff"});
ret.add(new String[]{});
return ret;
}
private static List<String[]> getMovesReset() {
List<String[]> ret = new ArrayList<String[]>();
ret.add(new String[]{"osNY9Aw3DbSgBFPW6","#000000"});
ret.add(new String[]{"Rqy3C3W84ebuXmLF2","#000000"});
ret.add(new String[]{"5FKw4ydT67nH28Zsw","#000000"});
ret.add(new String[]{"6F5Rsay9X9dSwgbGp","#000000"});
ret.add(new String[]{"ezZZvc63oXBxRihLo","#000000"});
ret.add(new String[]{"uzk8ZnGQheN8Sjyj4","#000000"});
ret.add(new String[]{"8TQy7kH4AszpKX7DC","#000000"});
ret.add(new String[]{"z5arsNe8ZwKzHsith","#000000"});
ret.add(new String[]{"t57MBG5AZEinmGC6E","#000000"});
ret.add(new String[]{"TsvPKYMGE5RRbn9NM","#000000"});
ret.add(new String[]{"33Yn3n2DQhZxy2FHx","#000000"});
ret.add(new String[]{"TfL4ktfYh7Qe93LpR","#000000"});
ret.add(new String[]{"f59B3A9g8kcvvgfkd","#000000"});
ret.add(new String[]{"uj868d6gM4PXQDCGq","#000000"});
ret.add(new String[]{"cjgSsof44YbcYnGhh","#000000"});
ret.add(new String[]{"xPnWT4xXLzHYJk9qk","#000000"});
ret.add(new String[]{"Y4MwMXcsPaumzSoy6","#000000"});
ret.add(new String[]{"znYosDMf6gELs3bfW","#000000"});
ret.add(new String[]{"d5MTvecDNCktbPCkt","#000000"});
ret.add(new String[]{"9kSFupjGugxstQPBc","#000000"});
ret.add(new String[]{"jZD3w92ZJgccHN6XW","#000000"});
ret.add(new String[]{"r6bzb2ZKdrvK8mcse","#000000"});
ret.add(new String[]{"kohuYLGN3NJFAv8hp","#000000"});
ret.add(new String[]{"7aFPLzfrSw4ZsJqhY","#000000"});
ret.add(new String[]{"3m52FqtjBzxfpn6kY","#000000"});
ret.add(new String[]{"bibT9WLHWvnSLKxJb","#000000"});
return ret;
}
public static void draw(DdpClient client, String pixel, String color) throws InterruptedException{
Map<String,Object> first = new HashMap<String,Object>();
first.put("_id", pixel);
Map<String,Object> second = new HashMap<String,Object>();
Map<String,Object> secondValue = new HashMap<String,Object>();
secondValue.put("color",color);
secondValue.put("painter",USER);
secondValue.put("when",""+System.currentTimeMillis());
second.put("$set", secondValue);
client.call("/pixels/update", new Object[]{
first,
second,
new HashMap<String,String>()
});
Thread.sleep(400);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment