Skip to content

Instantly share code, notes, and snippets.

View tjklemz's full-sized avatar

Thomas Klemz tjklemz

View GitHub Profile
{
"_links": {
"self": { "href": "... /api" },
"reports": { "href": "... /reports/groups" },
"other" : { "href": "..." }
}
}
{
{ "rel": "report", "_links": { "href": "..." }, "someAttribute": "..." },
{ "rel": "report", "_links": { "href": "..." }, "someAttribute": "..." },
{ "rel": "report", "_links": { "href": "..." }, "someAttribute": "..." },
{ "rel": "report", "_links": { "href": "..." }, "someAttribute": "..." },
...
}
@tjklemz
tjklemz / 001-hal-reports-response
Created February 8, 2015 06:57
embedded vs links
{
"_links": {
"self": { "href" : "https://cloud.paulmarsoftware.com/api/nobl/reports" },
"group": [
{ "title": "Accounting", "href" : "https://cloud.paulmarsoftware.com/api/nobl/reports/accounting" },
{ "title": "Account Details", "href" : "https://cloud.paulmarsoftware.com/api/nobl/reports/account-details" },
...
...
]
}
DECLARE Id INT, @Title VARCHAR(50)
DECLARE Iterator CURSOR FORWARD_ONLY FOR
SELECT Id, Title FROM dbo.SourceTable
OPEN Iterator
WHILE 1=1 BEGIN
FETCH NEXT FROM @InputTable INTO @Id, @Title
IF @@FETCH_STATUS < 0 BREAK
PRINT 'Do something with ' + @Title
END
CLOSE Iterator
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Producer Commission",
"description": "Producer commission statements",
"type": "object",
"properties": {
"startDate": {
"title": "Start Date",
"type": "string",
"format": "date"
{
"_links": {
"self": { "href": "/customers/1234" },
"collection": { "href": "/customers" }
},
"name": "Bob Jones",
"street": "123 California Ave",
"city": "Sacramento",
"state": "CA",
"zip": "12345",
{
"_links": {
"self": "/contacts"
},
"_embedded": {
"contact": [{
"_links": {
"self": { "href": "/contacts/1" }
},
"name": "Bob Marley",
function createBranch(repo, newBranchName, remoteName, remoteBranch) {
var remoteRefBase = 'refs/remotes/' + remoteName;
var remoteRefName = remoteRefBase + '/' + remoteBranch;
var remoteRefHead = remoteRefBase + '/' + 'HEAD';
return NodeGit.Reference.symbolicCreate(repo, remoteRefHead, remoteRefName, 1, 'Setting HEAD')
.then(function () {
return repo.getReference(remoteRefName);
})
.then(function (remoteRef) {
function merge (repo, remotePath) {
var remoteName = 'superman';
var remoteBranch = 'master'
var remoteHeadRef = 'refs/remotes/' + remoteName + '/HEAD';
var remoteMasterRef = 'refs/remotes/' + remoteName + '/master';
var ourBranchName = 'master';
var newBranchName = 'wonderwoman';
NodeGit.Remote.create(repo, remoteName, remotePath);
@tjklemz
tjklemz / asyncAll.js
Last active October 5, 2018 04:52
asyncAll example
/*
* A simple asyncAll example.
*
* Ignores any error handling and only returns the results to the done callback.
* Each task is expected to take a callback for its first parameter.
*/
// Example call:
asyncAll([doSomething, doSomethingElse], function (results) {
console.log('all done', results);