This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -w | |
my $file = $ARGV[0]; | |
my $bad = 0; | |
open(my $FH, "<", $file); | |
while(<$FH>) { | |
if ((length) > 50) { | |
print("line $. too long\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import string | |
pronMap = {"i": "you", | |
"you": "you", | |
"they": "they", | |
"we": "you", | |
"he": "he", | |
"she": "she", | |
"it": "it"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import string | |
from errbot import BotPlugin, botcmd | |
class ofhave(BotPlugin): | |
def callback_message(self, conn, mess): | |
reply = self.couldShould(mess.getBody()) | |
if reply: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(NSArray*)valuesForRevision:(CDTDocumentRevision*)revision | |
indexName:(NSString*)indexName | |
{ | |
NSMutableArray *returnArray = [NSMutableArray array]; | |
NSArray *arr = [[revision body] valueForKey:@"subjects"]; | |
for (NSDictionary *dict in arr) { | |
[returnArray addObject:[dict valueForKey:@"mark"]]; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void test1() throws Exception { | |
// NB replicator is a BasicReplicator object we created earlier | |
MutableDocumentRevision doc = new MutableDocumentRevision(); | |
doc.body = DocumentBodyFactory.create("{\"hello\": \"world\"}".getBytes()); | |
doc.attachments.put("att1", new UnsavedFileAttachment(new File("/tmp/1"), "text/plain")); | |
BasicDocumentRevision doc1 = datastore.createDocumentFromRevision(doc); | |
replicator.start(); | |
Assert.assertEquals(Replicator.State.STARTED, replicator.getState()); | |
while(replicator.getState() != Replicator.State.COMPLETE) { | |
Thread.sleep(1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void forceInsert_noCommonHistory() throws Exception { | |
// rev6 represents the current state after we lost all of the history from 1 -> 5 | |
BasicDocumentRevision rev6 = createDbObject("6-x", bodyOne); | |
// rev7 represents an incoming change which has deleted set | |
BasicDocumentRevision rev7 = createDbObject("7-x", bodyTwo); | |
//BasicDocumentRevision rev7 = createDbObjectDeleted("7-x"); | |
// rev2 represents an incoming change which will not have an ancestor because it was lost | |
BasicDocumentRevision rev2 = createDbObject("2-x", bodyTwo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private BasicDocumentRevision createDbObjectDeleted(String rev) { | |
DocumentRevisionBuilder builder = new DocumentRevisionBuilder(); | |
builder.setDocId(OBJECT_ID); | |
builder.setRevId(rev); | |
builder.setDeleted(true); | |
builder.setBody(new BasicDocumentBody(JSONUtils.EMPTY_JSON)); | |
return builder.build(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cloudant.com.testsensorupload; | |
import android.os.AsyncTask; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Base64; | |
import android.widget.TextView; | |
import java.io.IOException; | |
import java.io.InputStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void blah() throws Exception { | |
Map<String, String> map = new HashMap<String, String>(); | |
map.put("hello", "world"); | |
// create a doc | |
DocumentRevision revision = new DocumentRevision("id1"); | |
revision.setBody(DocumentBodyFactory.create(map)); | |
datastore.createDocumentFromRevision(revision); | |
// fetch up to 100 changes since the beginning | |
Changes changes = datastore.changes(0, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)testCompactedConflictedTree | |
{ | |
NSError * error; | |
CDTDocumentRevision *mutableRev; | |
mutableRev = [CDTDocumentRevision revisionWithDocId:@"aTestDocId"]; | |
mutableRev.body = [@{ @"hello" : @"world" } mutableCopy]; | |
CDTDocumentRevision * rev = [self.datastore createDocumentFromRevision:mutableRev error:&error]; | |
XCTAssertNotNil(rev, @"Document was not created"); |
OlderNewer