Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

46
LINES

< > BotCompany Repo | #1001216 // Snippet Cache Bot

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1428L/9K/33K).

!747

m {
  static new L<S> entries;
  
  p {
    readLocally("entries");
    print(entries.size() + " entries in cache. Not consolidated.");
    makeAndroid("Snippet Cache Bot.");
  }
  
  static synchronized void consolidate() {
    new Map<S, S> byID;
    for (S e : entries) {
      new Matches m;
      if (!find3("snippet *", e, m))
        print("Dropping weird entry: " + quote(e));
      S id = formatSnippetID(unquote(m.m[0]));
      byID.put(id, e);
    }
    entries = new ArrayList<S>(byID.values());
    saveLocally("entries");
  }
  
  static synchronized S answer(S s) {
    new Matches m;
    
    // new information to store
    
    if (match3("meta * - just got it from the web. snippet * now has md5 * and title *.", s, m)) {
      print("New entry: " + structure(m.m));
      entries.add(s);
      saveLocally("entries");
      return "OK, stored.";
    }
    
    // other commands
    
    if (match3("please consolidate", s, m)) {
      consolidate();
      return "OK, consolidated to " + entries.size() + " entries.";
    }
    
    return null;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1001216
Snippet name: Snippet Cache Bot
Eternal ID of this version: #1001216/1
Text MD5: ffdaaee726e1d6fd426f65e37c44f02d
Transpilation MD5: ac653791c7f9c788f6cd356edfc3ec78
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-04 14:33:50
Source code size: 1123 bytes / 46 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 548 / 563
Referenced in: [show references]