Skip to content

Instantly share code, notes, and snippets.

Craig Rodrigues CraigRodrigues

Block or report user

Report or block CraigRodrigues

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@CraigRodrigues
CraigRodrigues / practiceSpec.js
Last active Mar 1, 2018
Function Practice Assertions
View practiceSpec.js
// Setup
mocha.setup('bdd');
chai.should();
chai.config.includeStack = false;
const assert = chai.assert;
describe('addTwoNumbers', () => {
it('Adds two positive numbers', function() {
assert.equal(addTwoNumbers(10, 2), 12);
View gist:fb5ac0f00cb317c9c17f91fed7ae2ce2
// Copyright 2013 Soundslice LLC. License: BSD.
/* HTML example: ****************
<figure class="vid">
<video preload>
<source src="/videos/help/playhead.mp4" type="video/mp4">
<source src="/videos/help/playhead.webm" type="video/webm">
</video>
<p>To move the playhead, click in the timeline or drag the playhead’s diamond.</p>
View gist:0e8cab2f84c3bd8ff59f1f3b7d2a62a9
// Copyright 2013 Soundslice LLC. License: BSD.
/* HTML example: ****************
<figure class="vid">
<video preload>
<source src="/videos/help/playhead.mp4" type="video/mp4">
<source src="/videos/help/playhead.webm" type="video/webm">
</video>
<p>To move the playhead, click in the timeline or drag the playhead’s diamond.</p>
@CraigRodrigues
CraigRodrigues / bubbleSort.js
Last active Apr 25, 2019
Bubble Sort in Javascript
View bubbleSort.js
// Normal
const bubbleSort = function(array) {
let swaps;
do {
swaps = false;
for (let i = 0; i < array.length - 1; i++) {
if (array[i] > array[i + 1]) {
let temp = array[i + 1];
array[i + 1] = array[i];
array[i] = temp;
View toyProblems.js
/**
* Given a single input string, write a function that produces all possible anagrams
* of a string and outputs them as an array. At first, don't worry about
* repeated strings. What time complexity is your solution?
*
* Extra credit: Deduplicate your return array without using uniq().
*/
/**
* example usage:
@CraigRodrigues
CraigRodrigues / reduce.js
Created Nov 20, 2016
Simple reduce function
View reduce.js
// array to reduce
// combine is a function that will do something to the current value and the current element
// current is either the start provided or 0 if nothing is provided?
function reduce(array, combine, start) {
var current = start || 0;
for (var i = 0; i < array.length; i++)
current = combine(current, array[i]);
return current;
}
@CraigRodrigues
CraigRodrigues / convert.js
Created Nov 18, 2016
Converting cm to inches to nearest 1/16th inch
View convert.js
// The company I work for creates custom acrylic cases based on customer's inputted dimensions.
// For fabrication our dimensions go down to the nearest 1/16th inch.
// International customers may use cm (or mm) and this is a program that will attempt to convert cm to inches
// down to the nearest 16th of an inch and display the result as a reduced fraction.
// 1 cm is equivalent to 0.39370 inches.
// EXAMPLE: 16.4 cm = 6 7/16 inches
// EXAMPLE: 10.5 cm = 4 2/16 or 4 1/8 inches
@CraigRodrigues
CraigRodrigues / phone.js
Created Oct 6, 2016
YDKJS - Up & Going - Challenge #1
View phone.js
var bankAccount = prompt("How much money is in your bank account?");
var spendingLimit = prompt("What is the max amount mof money do you wish to spend?")
var phonePrice = 100, accessoryPrice = 20, taxRate = 0.06, cost = 0;
function finalCheckout(amt) {
amt = amt + (amt * taxRate);
if (amt < bankAccount)
console.log("You can afford this!");
else
@CraigRodrigues
CraigRodrigues / server.c
Created Sep 21, 2016
CS50 Problem Set 6: Web Server
View server.c
//
// server.c
//
// Computer Science 50
// Problem Set 6
//
// feature test macro requirements
#define _GNU_SOURCE
#define _XOPEN_SOURCE 700
@CraigRodrigues
CraigRodrigues / dictionary.c
Created Sep 8, 2016
CS50 Problem Set 5 - Mispellings
View dictionary.c
/**
* dictionary.c
*
* Computer Science 50
* Problem Set 5
*
* Implements a dictionary's functionality.
*/
#include <stdbool.h>
You can’t perform that action at this time.