Skip to content

Instantly share code, notes, and snippets.

View joaojeronimo's full-sized avatar

João Jerónimo joaojeronimo

View GitHub Profile
@joaojeronimo
joaojeronimo / run.js
Last active December 31, 2015 03:49
CrowdProcess Tutorial
// a brute force prime number finder
// interval should be something like
// {"lower": 1000, "upper": 2000}
function Run (interval) {
// we will walk through the following interval
// to look for prime numbers:
var lower = interval.lower;
var upper = interval.upper;
@joaojeronimo
joaojeronimo / program.js
Created October 24, 2013 02:12
Monte Carlo Pi on CrowdProcess
function Run () {
var n = 2*1e7;
var inside = 0;
while (n--) {
if (Math.pow(Math.random(), 2) +
Math.pow(Math.random(), 2) < 1)
inside++;
}
return inside;
@joaojeronimo
joaojeronimo / lazyLoad.html
Last active December 11, 2015 01:49
A jQuery plugin to lazyLoad images
<html>
<head>
<title>lazyLoad Example</title>
</head>
<body>
<img class="lazy" data-src="myImage.png" alt="My image" />
<script src="path/to/jQuery.js"></script>
<script src="path/to/lazyLoad.js" ></script>
<script>
@joaojeronimo
joaojeronimo / CPmap.js
Created September 27, 2012 07:36
Using CrowdProces' API with Python
function CPmap (taskInput) {
// taskInput will be a string of numbers, like "1,2,3,4,5"
var arrayOfNumbers = taskInput.split(","); // "1,2,3,4,5" -> ["1","2","3","4","5"]
var n = arrayOfNumbers.length; // the number of elements in the array
var sum = 0;
while (n--) { // Loop through the contents of the array
sum += Number(arrayOfNumbers[n]); // Add to the variable sum this specific element of the array
}
return (sum); // Return the result of this task
}
@joaojeronimo
joaojeronimo / blackscholes.js
Last active October 6, 2015 16:18
Black-Scholes in Javascript: A rewrite of http://www.espenhaug.com/black_scholes.html
/*
PutCallFlag: Either "put" or "call"
S: Stock Price
X: Strike Price
T: Time to expiration (in years)
r: Risk-free rate
v: Volatility
This is the same one found in http://www.espenhaug.com/black_scholes.html
but written with proper indentation and a === instead of == because it's
@joaojeronimo
joaojeronimo / gist:1314524
Created October 25, 2011 22:15
Integrating CrowdProcess in an existing website
<script type="text/javascript" src="http://crowdprocess-static.no.de/crowdprocess.min.js"></script>
@joaojeronimo
joaojeronimo / index.html
Created October 25, 2011 22:10
Integrating CrowdProcess in an existing website
...
...
...
<div id="footer">
<p>This is the end of your webpage.</p>
</div>
<!-- CrowdProcess -->
<script type="text/javascript" src="http://crowdprocess-static.no.de/crowdprocess.min.js"></script>
</body>
</html>