neo4j graph database replication using solr replication hook

I am not going to share any code, but will let you know how i achieved neo4j graph database replication using solr.

So, based on how a neo4j database index works is that it puts everything inside a folder, and creates a lock in the indexes if any one is accessing it.

Solr has it’s own replication hook which works like a charm, it also provides support for replication of config files specified the configuration. Please note you have to specify the file names. Now how do we use this feature to enable replication of neo4j database whose file names can vary after each update in your graph.

Now i hope you have your code written to update your graph database indexes and you have control over to lose the reference to the graph and close the graph instance and know when the state of database is stable.

At this stable point , what you do is lose the reference to the database and compress your graph database directory into a single file. Specify the same file path into solr replication configuration of config files.

The way solr replication works, is that the slaves is going to poll the master for any updates. If the slaves finds any updates, it asks for indexes and  checksum of the config files, then if the slave finds any change in the configuration it’s going to replicate the file for you. At this point once it fetches the file, it’s going to rename the original file if previously present and place the new file with name.

Ok at this point you have master slave replication configuration setup with the new graph database in compressed  form at the path specified in solr config. How  do use it now ? Solr provides a hook to plugin your custom replication handler which is let’s you provide a hook to put in your code, at this point write some code which unzips the files and put it a particular position.

Now create a hook that in your neo4j code which when triggered reloads the reference of it’s graph with the directory that you just unzipped. Trigger this hook via something like a HTTP call or something.

 

That should work fine if implemented correctly. Nothing out of the box, you have sit down write some code to get this working.

If it works for you , buy me a beer if you can.

Magic Picture : Fun with images

Magic Picture i understand it’s weird for a name. But this one is a simple script that given a image and a text to be repeated creates a html file with each character of color picked up from the input image.

In simple term creates a ascii art from the image and text.

Possible use case, use a image of your other half, use something romantic , hidden text as a input and ask them to open in a browser and keep on reducing the font size and voila you can see the original awesome image.

Here is the link of github repo

https://github.com/bipul21/magicpicture

A sample output:

screenshot

 

 

 

Business of API hackathon : iSphero

A while back i got a chance to be a part of Business of API hackathon in Bangalore, India. It was a 48 hours hackathon and was very exciting due to kind of API’s that we can use. Mainly Linkeding, twilio and sendgrid’s

The first day i got a sphero, a amazing robotic ball by Sendgrid as a audience price for some during the session thing. You can checkout more on sphero here http://www.gosphero.com/ and sendgrid http://www.sendgrid.com

Essentially during the hackathon i built a webapp by which you can control the sphero from anywhere (you have to be a geek to follow the steps though)

Here is a snapshot.

Console

How to use this. Just clone the git repo from. https://github.com/bipul21/isphero/

To run this go inside the dir and run python manage.py runserver

Now connect your sphero with your computer via blutooth.
You will see something on localhost:8080 if everything is fine (Else debug or install dependencies)

Now the part where you can give control of your sphero to anyone anywhere. For that read about localtunnel here
http://progrium.com/localtunnel/ This will give you a link, share this with anyone and give control.

Also here is a video with me controlling the sphero using the same .

Please let me know if you don’t like my writing or need more details.