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
function flatten(arr) { | |
return arr.reduce((flat, item) => | |
flat.concat(Array.isArray(item) ? flatten(item) : item), []) | |
} | |
// usage: | |
flatten([[1,2,[3]], 4]) // [1,2,3,4] |
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
# Some useful random Bash utils, mostly for working with NodeJS projects. I use `dep` and `findjs` the most. :) | |
# You can just stuff these in your .bashrc or .zshrc | |
alias bork='rm -rf ./node_modules && yarn install' | |
# an actual bork: | |
# alias bork='find ./node_modules -type d -depth 1 | sort -R | sed 1q | rm -rf' | |
# simple libre: | |
# alias libre='find . -type d -name "node_modules" -prune -o -name "package-lock.json" -exec rm {} \;' |
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
/* | |
* 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); |
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
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); | |
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
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) { |
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
{ | |
"_links": { | |
"self": "/contacts" | |
}, | |
"_embedded": { | |
"contact": [{ | |
"_links": { | |
"self": { "href": "/contacts/1" } | |
}, | |
"name": "Bob Marley", |
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
{ | |
"_links": { | |
"self": { "href": "/customers/1234" }, | |
"collection": { "href": "/customers" } | |
}, | |
"name": "Bob Jones", | |
"street": "123 California Ave", | |
"city": "Sacramento", | |
"state": "CA", | |
"zip": "12345", |
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
{ | |
"$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" |
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
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 |
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
{ | |
"_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" }, | |
... | |
... | |
] | |
} |