Skip to content

Instantly share code, notes, and snippets.

/**
* Identity.validateToken
*
* This is an administrative API that allows a admin user to validate the token of
* another authenticated user.
*
* @param {String} token the token to validate
* @param {String|Function} [belongsTo] The tenantId of the user to match with the token
* @param callback
*/
var pkgcloud = require('pkgcloud'),
_ = require('underscore');
var client = pkgcloud.providers.rackspace.dns.createClient(require('./config.json'));
client.getRecords(process.argv[2], function (err, records) {
if (err) {
console.dir(err);
}
@kenperkins
kenperkins / README.md
Last active July 22, 2022 04:46
Creating and uploading files a CDN enabled container

Setup for node, npm & pkgcloud

First you'll need to make sure your system has a c++ compiler. For OSX, XCode will work, for Ubuntu, the build-essential and libssl-dev packages work.

Install script

To install you could use the install script (requires Git) using cURL:

curl https://raw.github.com/creationix/nvm/master/install.sh | sh
@kenperkins
kenperkins / app.js
Last active December 19, 2015 15:29
app.use(express.cookieParser());
app.use(express.cookieSession({key: 'somekey', secret: 'somethingsecret'}));
app.use(function(req ,res, next) {
app.locals.session = req.session;
next();
});
app.set('views', __dirname + '/views')
app.set('view engine', 'ejs')
app.use(express.static(__dirname + '/public'))
app.use(lessMiddleware({
@kenperkins
kenperkins / creds.json
Created June 13, 2013 17:07
pkgcloud with creds in a json file
{
"username": "your-username",
"apiKey": "your-api-key"
}
@kenperkins
kenperkins / basic.js
Created May 30, 2013 15:22
Simple problem with Formidable
// this works
form.onPart = function(part) {
if (part.filename == null) {
return form.handlePart(part);
}
part.pipe(someWriteableStream);
}
@kenperkins
kenperkins / client.js
Last active December 17, 2015 21:19
Simple Client Upload Piped to Rackspace
var baseUri, form, fs, r, request;
request = require('request');
fs = require('fs');
baseUri = 'http://localhost:8000';
r = request.post(baseUri + '/images', function (err, res, body) {
if (err) {
@kenperkins
kenperkins / simple.js
Created May 24, 2013 02:55
This program never exists
var tls = require('tls');
var stream = tls.connect(12345, 'myhost.com', {
rejectUnauthorized: false
});
@kenperkins
kenperkins / winston-with-pkgcloud.js
Created May 22, 2013 04:16
Using Winston with Pkgcloud
var pkgcloud = require('pkgcloud'),
winston = require('winston'),
_ = require('underscore');
var logger = new winston.Logger({
levels: {
debug: 0,
verbose: 1,
info: 3,
warn: 4,
@kenperkins
kenperkins / sync-buckets.js
Last active December 17, 2015 12:59
This syncs two buckets on cloud files.
var pkgcloud = require('pkgcloud'),
async = require('async'),
log = require('../common/logging'),
http = require('http');
var logger = log.getLogger('debug');
// Make sure we don't run out of global file handles;
// Haven't tried fine tuning this to be lower
http.globalAgent.maxSockets = 1000;