Skip to content

Instantly share code, notes, and snippets.

// Bonfire: Pig Latin
// Author: @tylerl-uxai
// Challenge: http://www.freecodecamp.com/challenges/bonfire-pig-latin
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function translate(str) {
var regex = /[aeiou]/gi;
if (str[0].match(regex)){
return str + "way";
} else if (str[1].match(regex)){
// Bonfire: Search and Replace
// Author: @tylerl-uxai
// Challenge: http://www.freecodecamp.com/challenges/bonfire-search-and-replace
// Learn to Code at Free Code Camp (www.freecodecamp.com)
// Rewritten by myself with the help of https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Bonfire-Search-and-Replace
function myReplace(str, before, after) {
var i = str.indexOf(before);
if (str[i] == str[i].toUpperCase()){
// Bonfire: Where art thou
// Author: @tylerl-uxai
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-art-thou
// Learn to Code at Free Code Camp (www.freecodecamp.com)
// Rewritten myself with help from https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Bonfire-Where-art-thou
function where(collection, source) {
// speed test
var keys = Object.keys( source ); // returns the keys to the variable
// Bonfire: Roman Numeral Converter
// Author: @tylerl-uxai
// Challenge: http://www.freecodecamp.com/challenges/bonfire-roman-numeral-converter
// Learn to Code at Free Code Camp (www.freecodecamp.com)
// re-wrote by myself with the aid of http://wulkan.me/bonfire-roman-numeral-converter/
function convert(num) {
var romanNumerals = '',
decimals = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],
numerals = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
// Bonfire: Diff Two Arrays
// Author: @tylerl-uxai
// Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays
// Learn to Code at Free Code Camp (www.freecodecamp.com)
// with the help of http://wulkan.me/bonfire-diff-two-arrays/ and https://github.com/pfilippi24
function diff(arr1, arr2) {
// Same, same; but different.
return arr1.concat(arr2).filter(function(val){
return !(arr1.indexOf(val)>=0 && arr2.indexOf(val) >=0);
function p = predict(theta, X)
%PREDICT Predict whether the label is 0 or 1 using learned logistic
%regression parameters theta
% p = PREDICT(theta, X) computes the predictions for X using a
% threshold at 0.5 (i.e., if sigmoid(theta'*x) >= 0.5, predict 1)
m = size(X, 1); % Number of training examples
% You need to return the following variables correctly
p = zeros(m, 1);
Running Gradient Descent ...
ans =
32.0727
Theta found by gradient descent: 0.000000 0.000000
For population = 35,000, we predict a profit of 0.000000
For population = 70,000, we predict a profit of 0.000000
function J = computeCost(X, y, theta)
%COMPUTECOST Compute cost for linear regression
% J = COMPUTECOST(X, y, theta) computes the cost of using theta as the
% parameter for linear regression to fit the data points in X and y
% Initialize some useful values
m = length(y); % number of training examples
% You need to return the following variables correctly
function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
%GRADIENTDESCENT Performs gradient descent to learn theta
% theta = GRADIENTDESENT(X, y, theta, alpha, num_iters) updates theta by
% taking num_iters gradient steps with learning rate alpha
% Initialize some useful values
m = length(y); % number of training examples
J_history = zeros(num_iters, 1);
for iter = 1:num_iters

Experimental Generation of Interpersonal Closeness

Instructions to Subjects Included With Task Slips Packet

This is a study of interpersonal closeness, and your task, which we think will be quite enjoyable, is simply to get close to your partner. We believe that the best way for you to get close to your partner is for you to share with them and for them to share with you. Of course, when we advise you about getting close to your partner, we are giving advice regarding your behavior in this demonstration only, we are not advising you about your behavior outside of this demonstration.

In order to help you get close we've arranged for the two of you to engage in a kind of sharing game. You're sharing time will be for about one hour, after which time we ask you to fill out a questionnaire concerning your experience of getting close to your partner.

You have been given three sets of slips. Each slip has a question or a task written on it. As soon as you both finish reading these instructions, you should