Skip to content

Instantly share code, notes, and snippets.

@jpina
jpina / compile_svn_1.7.20_centos.sh
Last active June 27, 2018 17:14
Compile SVN 1.7.20 with neon support (Centos 6 / Fedora 21)
#!/bin/bash
SOURCE_DIR=/usr/local/src
SVN_VERSION=1.7.20
SVN_SRC_DIR=$SOURCE_DIR/subversion-$SVN_VERSION
# Install dependencies
sudo yum -y groupinstall "Development Tools" "Development Libraries"
sudo yum -y install libxml2 libxml2-devel libxslt-devel openssl openssl-devel
@jpina
jpina / compile_svn_1.7.20_ubuntu.sh
Created November 24, 2015 10:24
Compile SVN 1.7.20 with neon support (Ubuntu 14.04)
#!/bin/bash
# Get script path
SOURCE_DIR=/usr/local/src
SVN_VERSION=1.7.20
SVN_SRC_DIR=$SOURCE_DIR/subversion-$SVN_VERSION
# Install dependencies
sudo apt-get -y install build-essential libxml2 libxml2-dev libxslt1-dev openssl libssl-dev
@jpina
jpina / promise_api_reference.md
Created November 25, 2015 11:00
00 Promise API Reference

Promise API Reference

Static Methods

Promise.resolve(promise);

Returns promise (only if promise.constructor == Promise)

Promise.resolve(obj);

Make a promise that fulfills to obj. in this situation.

@jpina
jpina / 07_parallelism.js
Created November 25, 2015 11:01
07 Parallelism
Promise.all(arrayOfPromises).then(function(arrayOfResults) {
//...
});
/*****************************************************************/
@jpina
jpina / 06_error_handling.js
Created November 25, 2015 11:02
06 Error Handling
get('story.json').then(function(response) {
console.log("Success!", response);
}, function(error) {
console.log("Failed!", error);
});
/************************************************/
@jpina
jpina / 05_queuing.js
Created November 25, 2015 11:03
05 Queuing asynchronous actions
getJSON('story.json').then(function(story) {
return getJSON(story.chapterUrls[0]);
}).then(function(chapter1) {
console.log("Got chapter 1!", chapter1);
});
/*************************/
@jpina
jpina / 04_chaining.js
Created November 25, 2015 11:03
04 Chaining
var promise = new Promise(function(resolve, reject) {
resolve(1);
});
promise.then(function(val) {
console.log(val); // 1
return val + 2;
}).then(function(val) {
console.log(val); // 3
});
@jpina
jpina / 03_promisifying_xmlhttprequest.js
Created November 25, 2015 11:03
03 Promisifying XMLHttpRequest
function get(url) {
// Return a new promise.
return new Promise(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
@jpina
jpina / 02_how_to_use_a_promise.js
Created November 25, 2015 11:04
02 How to use a promise
promise.then(function(result) {
console.log(result); // "Stuff worked!"
}, function(err) {
console.log(err); // Error: "It broke"
});
@jpina
jpina / 01_promise.js
Created November 25, 2015 11:04
01 Promise API
var promise = new Promise(function(resolve, reject) {
// do a thing, possibly async, then…
if (/* everything turned out fine */) {
resolve("Stuff worked!");
}
else {
reject(Error("It broke"));
}
});