Skip to content

Instantly share code, notes, and snippets.

@adaau
adaau / gist:dd37655f9820248e6190
Created November 16, 2015 01:50
Assessment_MongoDB
QUESTIONS
What is MongoDB?
MongoDB is a NoSQL database
Why do we need a Database?
To store data, which will allow us to access and manipulate it.
What format does MongoDB use to store data?
Binary JSON - similar to JSON but with other data types including ObjectId and Date
@adaau
adaau / mp.js
Created November 13, 2015 02:13
Assessment_mult_persistence
var steps = 1
function findProduct(array) {
var product = array.reduce(function(prev, curr) {
return prev * curr;
}, 1);
if (product < 10) {
console.log(steps);
return steps;
}
else {
@adaau
adaau / mp.js
Created November 13, 2015 02:11
Assessment_multiplicative_persistence
var steps = 1
function findProduct(array) {
var product = array.reduce(function(prev, curr) {
return prev * curr;
}, 1);
if (product < 10) {
console.log(product);
console.log(steps);
return steps;
}
@adaau
adaau / js-triple-double.js
Created November 11, 2015 04:43
Assessment-JS-triple-double
var tripleDouble = function(first, second){
var firstArray = first.toString().split("");
var secondArray = second.toString().split("");
for (var i = 0; i < firstArray.length - 2; i++) {
if (firstArray[i] == firstArray[i + 1] && firstArray[i] == firstArray[i + 2]) {
for (var j = 0; j < secondArray.length - 1; j++) {
if (secondArray[j] == secondArray[j + 1]) {
return 1;
}
}
@adaau
adaau / gist:a93a230efe6fae54a50f
Created November 10, 2015 01:16
Assessment_Git_API
Given 3 branch master, feature1, and feature2. If you made a pull request on feature1 and feature2 on github and merged feature1. Then when you try to merge feature2 you realize that there are conflicts. What are the step you have to do so that you can merge feature2 on github?
1. Rebase the master of feature 2 branch:
In local of feature2:
gco master (so you are on master branch)
git pull --rebase origin master (to get all the changes from feature1)
gco feature2 (to go to feature2 branch)
git rebase master (to rebase feature2 branch with local master)
It will tell you that you have conflicts.
git status (to see which file(s) have the conflicts)
go to the file(s) that have the conflicts, decide which of the conflicted lines you want to keep
@adaau
adaau / frog.rb
Created October 28, 2015 02:22
Assessment_ruby_frog
def solution(x, a)
bridgeArray = []
timeArray = []
a.each do |elem|
if elem <= x
bridgeArray << elem unless bridgeArray.include?elem
timeArray << a.index(elem) unless timeArray.include?a.index(elem)
end
end
if bridgeArray.length == x
@adaau
adaau / roman.rb
Created October 27, 2015 03:21
Assessment_ruby_roman_to_arabic
# I have written to_arabic and to_roman methods, which work (except for cases such as 4 and 9)
# I am in the middle of writing a method to go through an array of roman / arabic numberals and applying the to_arabic or to_roman methods to them.
def transform(array)
array.each do |elem|
elem.to_arabic
end
end
def to_arabic(string)
@adaau
adaau / gist:12ec7f50afe525537a9d
Created October 21, 2015 03:27
Assessment - Ruby - FizzBuzz, 13 Digits
Question 1: Make a method that takes a number. Console log numbers that is a multiple of 3, 5, and 7 with fizz, buzz, russ respectively
@array = []
def fizz_buzz_russ(number)
@array = (1..number).to_a
@array.each do |i|
if (i % 105 == 0)
puts "fizzbuzzruss"
elsif (i % 21 == 0)
puts "fizzruss"
elsif (i % 15 == 0)
@adaau
adaau / ruby_lcm.rb
Created October 21, 2015 02:49
Assessment - Ruby LCM
Question 1
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 15?
Note: m evenly divides n means simply that n/m is an integer.
def gcd(a, b)
until b == 0 do
x = b
@adaau
adaau / gist:59c88cc4a25b34814820
Created October 15, 2015 07:35
WDI Project 1: Yamslam - 2 code snippets
// Player "keeps" dice by clicking on dice. Can make active again by clicking again.
var diceClick = function() {
$(".dice").on("click", function(event) {
var dice = $(this);
var value = parseInt(dice.children().attr('data-value'));
if (dice.css("opacity") == OPACFULL) {
dice.css("opacity", DICEOPACHALF);
dice.children().addClass("dice-kept");
game.keepDice(value);
checkCombo();