Cachita is a golang file and memory cache library
- Simple caching with auto type assertion included.
- In memory file cache index to avoid unneeded I/O.
- Msgpack based binary serialization using msgpack library for file caching.
API docs: https://godoc.org/github.com/gadelkareem/cachita.
Examples: https://godoc.org/github.com/gadelkareem/cachita#pkg-examples.
InstallationInstall:
go get -u github.com/gadelkareem/cachita
Development teams need to keep track of builds on Jenkins and sometimes an email alert is not flashy enough. Using this simple javascript on your team dashboard you can easily track failed builds and urge developers to fix it.
The script uses Jenkins JSON API with JSONP method to request the latest failed builds with author name and last commit that caused the failure. You will need to add the domain of the page where the request is sent to your “Jenkins” “Configure Global Security” “Domains from which to allow requests” configuration. Also the cookie from Jenkins is needed on the same browser so you will need to login to Jenkins from the same browser before running the script or proxy the request and use Basic Authorization using your API token to do the request.
//in api/models/User.js
function validationError(invalidAttributes, status, message) {
var WLValidationError = require('../../node_modules/sails/node_modules/waterline/lib/waterline/error/WLValidationError.js');
return new WLValidationError({
invalidAttributes: invalidAttributes,
status: status,
message: message
}
);
}
var User = {
attributes: {
//...
},
ownValidate:: function (values, update, cb) {
//example of not allowed param on update
//if it is an update then do not allow email param
if (update && values.email) {
return cb(validationError({
email: [
{
message: 'Email is not allowed for updates.'
}
]
}, 400 /*status*/));
}
sails.models['user'].findOne(values.email).exec(function (err, user) {
if (err) return cb(err);
if (user) {
return cb(validationError({
email: [
{
value: values.email,
rule: 'E_UNIQUE'
/* unique validation message is left for the default one here */
}
]
}, 409));
}
});
},
beforeCreate: function (values, cb) {
return sails.models['user'].ownValidate(values, false, cb);
},
beforeUpdate: function (values, cb) {
return sails.models['user'].ownValidate(values, true, cb);
}
}
For blueprint custom messages validation
I recently installed Disqus plugin for WordPress; however, I have been receiving this message “unable to connect to the disqus api servers.” By looking into the source code, it looks like curl is the problem! more specifically the _dsq_curl_urlopen() function, but I did not investigate this error further. As fortunately, we can easily switch to the alternative function _dsq_fsockopen_urlopen().