Skip to content

Instantly share code, notes, and snippets.

View anidotnet's full-sized avatar
🏠
Working from home

Anindya Chatterjee anidotnet

🏠
Working from home
View GitHub Profile
Path buildSubmarinePath(Size size) {
return Path()
..moveTo(size.width * 0.1950342, size.height * 7.270667)
..lineTo(size.width * 0.1646269, size.height * 7.270667)
..lineTo(size.width * 0.1646269, size.height * 7.041185)
..lineTo(size.width * 0.1604670, size.height * 7.041185)
..cubicTo(
size.width * 0.1576797,
size.height * 7.152261,
size.width * 0.1548923,
@anidotnet
anidotnet / pom.xml
Created May 11, 2017 03:47
Nitrite Introduction
<dependency>
<groupId>org.dizitart</groupId>
<artifactId>nitrite</artifactId>
<version>1.0</version>
</dependency>
@anidotnet
anidotnet / build.gradle
Created May 11, 2017 03:46
Nitrite Introduction
compile 'org.dizitart:nitrite:1.0'
@anidotnet
anidotnet / InitDatabase.java
Created May 11, 2017 03:44
Nitrite Introduction
Nitrite db = Nitrite.builder()
.compressed()
.filePath("/tmp/test.db")
.openOrCreate("user", "password");
@anidotnet
anidotnet / CreateCollection.java
Created May 11, 2017 03:44
Nitrite Introduction
// Create a Nitrite Collection
NitriteCollection collection = db.getCollection("test");
// Create an Object Repository
ObjectRepository<Employee> repository = db.getRepository(Employee.class);
@anidotnet
anidotnet / CreateDocument.java
Created May 11, 2017 03:43
Nitrite Introduction
// create a document to populate data
Document doc = createDocument("firstName", "John")
.put("lastName", "Doe")
.put("birthDay", new Date())
.put("data", new byte[] {1, 2, 3})
.put("fruits", new ArrayList<String>() {{ add("apple"); add("orange"); add("banana"); }})
.put("note", "a quick brown fox jump over the lazy dog");
@anidotnet
anidotnet / Insert.java
Created May 11, 2017 03:41
Nitrite Introduction
// insert the document
collection.insert(doc);
// update the document
collection.update(eq("firstName", "John"), createDocument("lastName", "Wick"));
// remove the document
collection.remove(doc);
@anidotnet
anidotnet / Query.java
Created May 11, 2017 03:40
Nitrite Introduction
Cursor cursor = collection.find(
// and clause
and(
// firstName == John
eq("firstName", "John"),
// elements of data array is less than 4
elemMatch("data", lt("$", 4)),
// elements of fruits list has one element matching orange
elemMatch("fruits", regex("$", "orange")),
// note field contains string 'quick' using full-text index
@anidotnet
anidotnet / Replication.java
Created May 11, 2017 03:35
Nitrite Introduction
// connect to a DataGate server localhost 9090 port
DataGateClient dataGateClient = new DataGateClient("http://localhost:9090")
.withAuth("userId", "password");
DataGateSyncTemplate syncTemplate
= new DataGateSyncTemplate(dataGateClient, "remote-collection@userId");
// create sync handle
SyncHandle syncHandle = Replicator.of(db)
.forLocal(collection)
// a DataGate sync template implementation
.withSyncTemplate(syncTemplate)
@anidotnet
anidotnet / 0_reuse_code.js
Created November 29, 2016 10:31
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console