Skip to content

Instantly share code, notes, and snippets.

View macikokoro's full-sized avatar

Joaquin Guardado macikokoro

View GitHub Profile
//var reverse = require('../app/reverse');
var pal = require('../app/pal');
var expect = require('chai').expect;
describe('palindrome', function() {
it('it is a palindrome', function() {
expect(pal('racecar')).to.be.true;
});
});
casper.test.begin("Testing if node express app", 2, function suite(test) {
casper.start('http://localhost:3000', function() {
test.assertHttpStatus(200);
});
casper.then(function() {
if (this.fetchText('.daysLeft' > 0)) {
this.echo("more than 0 days left");
}
this.echo("Days left: " + this.fetchText('.daysLeft'));
casper.test.begin('check if url is your blog', 1, function suite(test){
casper.start('http://personal-blog-site.herokuapp.com/', function(){
this.echo(this.getHTML('.nav h1'));
});
casper.then(function(){
test.assertTextExists('my blog', 'it is in fact, your blog');
});
casper.run(function(){
@macikokoro
macikokoro / repeatEliminate.js
Last active August 29, 2015 14:05
Find repeating numbers and eliminate the duplicates.
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 2, 2, 3,3,3,3];
//sort numbers in order
numArray.sort(function(a, b) {return a-b;});
//empty array to store results
var result = [];
//loop through array
for (var i = 0; i < numArray.length; i++) {
//compare results
if (numArray[i + 1] === numArray[i]) {
//push duplicates
@macikokoro
macikokoro / median.js
Created August 10, 2014 23:59
function that finds the median of a set of numbers
//Find the median
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 17, 25, 200];
numArray.sort(function(a, b) {return a-b;});
//log the contents of the array
console.log(numArray);
//log the array length
console.log("array length is: " + numArray.length);
//Split the array in half
@macikokoro
macikokoro / middle.js
Last active February 2, 2024 05:17
Finding the middle numbers in a array with javaScript
//Find the median
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 17, 25, 200, 210, 60];
numArray.sort(function(a, b) {return a-b;});
//log the contents of the array
console.log(numArray);
//log the array length
console.log("array length is: " + numArray.length);
//Split the array in half
@macikokoro
macikokoro / prcocessMedian.js
Created August 10, 2014 23:28
Thought process for finding the median of even and odd arrays
//Find median with console.log
var numArray = [2, 3, 6, 4, 8, 10, 11, 13, 1, 17, 25];
//sets array in order
numArray.sort(function(a, b) {return a-b;});
//splits array in half
var middle = Math.floor(numArray.length / 2);
console.log("the length in half is: " + middle);
//logs two middle numbers when array length is even
console.log("middle nums when array length is even: " + numArray[middle - 1] + " " + numArray[middle]);
@macikokoro
macikokoro / sortAscent.js
Last active August 29, 2015 14:05
Sorting an array numerically and ascending.
var numArray = [2, 4, 6, 4, 8, 10];
numArray.sort(function(a, b) {return a-b});
console.log(numArray);
@macikokoro
macikokoro / mean.js
Last active August 29, 2015 14:05
Finding the mean with javaScript
//Find mean
var numArray = [2, 4, 4, 6, 8, 10];
var mean = 0;
for (var i = 0; i < numArray.length; i++) {
mean += numArray[i];
}
//logs the length of the array
console.log(numArray.length);
//logs the result of adding the intengers in the array
#goto the node website
#click download
#click the source download
#go to the director you downloaded the source to
tar -xzvf <the node tar.gz you downloaded>
cd <node directory>
./configure --prefix=~/.node
make && make install
#add the following to your .bashrc or .profile