Skip to content

Instantly share code, notes, and snippets.

View akhilesh26's full-sized avatar

Akhilesh Kumar akhilesh26

View GitHub Profile
mastcoder@akhilesh ~/metabrainz/new/bookbrainz-site $ docker-compose logs elasticsearch
Attaching to elasticsearch
elasticsearch | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
elasticsearch | [2019-01-12T15:10:33,164][INFO ][o.e.n.Node ] [] initializing ...
elasticsearch | [2019-01-12T15:10:33,355][INFO ][o.e.e.NodeEnvironment ] [DTw3TOe] using [1] data paths, mounts [[/ (overlay)]], net usable_space [136gb], net total_space [174.5gb], types [overlay]
elasticsearch | [2019-01-12T15:10:33,355][INFO ][o.e.e.NodeEnvironment ] [DTw3TOe] heap size [990.7mb], compressed ordinary object pointers [true]
elasticsearch | [2019-01-12T15:10:33,357][INFO ][o.e.n.Node ] [DTw3TOe] node name derived from node ID [DTw3TOeSS2m3MRe9j21FgA]; set [node.name] to override
elasticsearch | [2019-01-12T15:10:33,357][INFO ][o.e.n.Node ] [DTw3TOe] version[6.3.2], pid[1
mastcoder@akhilesh ~/metabrainz/new/bookbrainz-site $ ./develop.sh
elasticsearch is up-to-date
postgres is up-to-date
redis is up-to-date
Waiting for elasticsearch:9200 ....elasticsearch: forward host lookup failed: Unknown host
..............elasticsearch: forward host lookup failed: Unknown host
............. ERROR: unable to connect
mastcoder@akhilesh ~/metabrainz/new/bookbrainz-site $
src/server/templates/target.js -> lib/server/templates/target.js
bookbrainz-site | src/types.js -> lib/types.js
bookbrainz-site |
bookbrainz-site | > bbsite@0.0.0 start /home/bookbrainz/bookbrainz-site
bookbrainz-site | > cross-env SSR=true node ./lib/server/app.js
bookbrainz-site |
bookbrainz-site | Elasticsearch ERROR: 2019-01-15T09:55:51Z
bookbrainz-site | Error: Request error, retrying
bookbrainz-site | HEAD http://elasticsearch:9200/bookbrainz => connect ECONNREFUSED 172.18.0.2:9200
bookbrainz-site | at Log.error (/home/bookbrainz/bookbrainz-site/node_modules/elasticsearch/src/lib/log.js:226:56)
/*
This program is checking the solution of sudoku of 9*9.
First sudoku solution is correct and second is not correct.
Uncomment one of them and check program works fine or not.
*/
// Correct solution
const sudoku = [
[8,3,5,4,1,6,9,2,7],
[2,9,6,8,5,7,4,3,1],
{
"id": "08f32a73-e415-4c7e-89ed-e496a621950e",
"name": "Artificial Intelligence: A Modern Approach",
"sort-name": "Artificial Intelligence",
"language": "English",
"type": "Book",
"added": "2018-02-05 08:40:30",
"addedBy": "574",
"aliases": [

The following list shows which data provided by API :-

There are five entity types of data model - publication, edition, work, creator and publisher.
For each entity type, the following data will be available:

  • list of entities
  • specific entity
  • list of aliases for entity
  • list of identifiers for entity
  • list of entity relationships
  • list of revisions for entity
"publication": [
{
"id": "08f32a73-e415-4c7e-89ed-e496a621950e",
"name": "Artificial Intelligence: A Modern Approach",
"sort-name": "Artificial Intelligence",
"language": "English",
"type": "Book",
"added": "2018-02-05 08:40:30",
"addedBy": "574",
//Emample of post reqest to add new publication from client application
curl -i -X POST \
-H '{"client_id":"oImVtuuVkDVCiWhANENM", "user_secret":"79461aea-b320-4f46-9978-3b444b3350c3", "Content-Type":"application/json"}' \
https://api.bookbrainz.com/v1/publications/new/ \
-d '{data pf new publication}'
//handle
router.get('publications/new', async(ctx) => {
if(isAuthenticated(ctx.request.header)){
// send data to the database and send response to client with status code.
@akhilesh26
akhilesh26 / CachingExample.js
Last active March 4, 2018 19:14
Caching will be manage by using redis
const Router = require('koa-router');
const router = new Router();
var redis = require('redis');
var client = redis.createClient(6379, '127.0.0.1');
router.get('/search', async(ctx) => {
var query = ctx.request.query.q;
client.get(query, (error,queryResult) => {
if(error){through error}
if(queryResult){
@akhilesh26
akhilesh26 / Join on bookbrainz Data
Last active February 27, 2018 14:46
Join query and output
const executeJoin = Publication.query((qb) => {
qb
.leftJoin(
'bookbrainz.revision',
'bookbrainz.publication.revision_id',
'bookbrainz.revision.id'
)
})
.fetch()
executeJoin.then((data) => {