This file contains hidden or 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
| 'use strict'; | |
| /* | |
| initialize npm and make sure you add the required dependencies | |
| $ npm init | |
| $ npm install hapi ioredis redlock --save | |
| } | |
| */ | |
| const Redlock = require('redlock'); | |
| const Redis = require('ioredis'); | |
| var client1 = new Redis(); |
This file contains hidden or 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
| class CommentResourceBuilder { | |
| def buildResource(Resource resource) { | |
| resource.definitions = | |
| resource.definitions | |
| .Comments { | |
| properties { | |
| body { | |
| type 'string' | |
| description 'Comments contents' | |
| } |
This file contains hidden or 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
| resource.definitions.Comment { | |
| properties { | |
| id { | |
| type 'Integer' | |
| description 'The comment id' | |
| } | |
| name { | |
| type 'String' | |
| description 'The comment name' | |
| } |
This file contains hidden or 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
| // ---------------------------------------------- | |
| // Builder implementation and supporting classes. | |
| // ---------------------------------------------- | |
| import groovy.transform.* | |
| @Canonical | |
| class Definition { | |
| Map<String, Schema> schemas = [:] | |
| def methodMissing(String name, args) { |
This file contains hidden or 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
| def defineRoute(routeBuilder) { | |
| // defining a "categories" endpoint | |
| routeBuilder."/categories" { | |
| // defining the "Category" schema | |
| schema Category { | |
| properties { | |
| // this is pure jsonschema, with a builder syntax | |
| name { | |
| type string | |
| description "a name" |
This file contains hidden or 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
| def defineRoute(routeBuilder) { | |
| routeBuilder.categories { | |
| schema { | |
| properties { | |
| name { | |
| type string, | |
| description "a name" | |
| } | |
| links { | |
| brand "brands" |
This file contains hidden or 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 groovy.text.SimpleTemplateEngine | |
| def rawTemplate = '''CREATE OR REPLACE TRIGGER ${owner}.${entityName}_INSERT | |
| AFTER INSERT | |
| ON ${owner}.${tableName} | |
| WHEN | |
| ${ columns.collect( { " old.$it <> new.$it" } ).join(/\n/) } | |
| BEGIN | |
| END''' |
This file contains hidden or 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
| @Grab('com.github.fge:json-schema-validator:2.2.6') | |
| @Grab('com.sparkjava:spark-core:2.1') | |
| import spark.* | |
| import static spark.Spark.* | |
| import com.github.fge.jackson.JsonLoader | |
| import com.github.fge.jsonschema.main.JsonSchemaFactory | |
| def factory = JsonSchemaFactory.byDefault() |
This file contains hidden or 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
| var gulp = require('gulp'); | |
| gulp.task('mongo-eval', function() { | |
| var Db = require('mongodb').Db, | |
| Server = require('mongodb').Server, | |
| assert = require('assert'); | |
| var db = new Db('local', new Server('localhost', 27017)); | |
| // Establish connection to db | |
| db.open(function(err, db) { |
This file contains hidden or 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
| sudo apt-get -y install git-flow | |
| npm install -g mocha gulp gg ungit | |
| sudo apt-get -y install zsh | |
| sed -i "s/alias gg='git gui citool'/alias ggg='git gui citool'/g" ~/.oh-my-zsh/plugins/git/git.plugin.zsh | |
NewerOlder