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).

1  
!747
2  
3  
m {
4  
  static new L<S> entries;
5  
  
6  
  p {
7  
    readLocally("entries");
8  
    print(entries.size() + " entries in cache. Not consolidated.");
9  
    makeAndroid("Snippet Cache Bot.");
10  
  }
11  
  
12  
  static synchronized void consolidate() {
13  
    new Map<S, S> byID;
14  
    for (S e : entries) {
15  
      new Matches m;
16  
      if (!find3("snippet *", e, m))
17  
        print("Dropping weird entry: " + quote(e));
18  
      S id = formatSnippetID(unquote(m.m[0]));
19  
      byID.put(id, e);
20  
    }
21  
    entries = new ArrayList<S>(byID.values());
22  
    saveLocally("entries");
23  
  }
24  
  
25  
  static synchronized S answer(S s) {
26  
    new Matches m;
27  
    
28  
    // new information to store
29  
    
30  
    if (match3("meta * - just got it from the web. snippet * now has md5 * and title *.", s, m)) {
31  
      print("New entry: " + structure(m.m));
32  
      entries.add(s);
33  
      saveLocally("entries");
34  
      return "OK, stored.";
35  
    }
36  
    
37  
    // other commands
38  
    
39  
    if (match3("please consolidate", s, m)) {
40  
      consolidate();
41  
      return "OK, consolidated to " + entries.size() + " entries.";
42  
    }
43  
    
44  
    return null;
45  
  }
46  
}

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: 616 / 649
Referenced in: [show references]