W5D2: Salvation, then to the orthodontist

I am so glad hell week is over, but I can't get too complacent. Hopefully the rest of the week runs as smoothly as this sprint did.

My orthodontist appointment today was at 6:15pm (couldn't have picked a better time, you idiot). Google Maps predicted that my trip would take 2 to 3 hours if I left at 4pm, so I gave myself another hour and left at 3pm. The trip still took 2 hours. After much poking, twisting, pulling and laser beaming, I came out of the orthodontist with a fresh one of these



Brushing my teeth today -- just felt like I was grinding my toothbrush across, what feels like, two bricks that are my teeth. What the hell did I sign up for? 3. Whole. Years. With metal latched on to my teeth.

MY TEETH FEEL LIKE LEAD AND I CAN'T EAT YUMMY STUFF


What we did today:
1. Toy Problem

Range Class

  • Build a class to represent a range of numbers that has:
    1. a beginning index
    2. an end index (optional). If there is no end index, the range should include only the passed-in start value.
    3. a ‘step’ (optional)
  • The step is the interval at which elements are included. For instance, a step of 1 includes every element in the range, while a step of 2 includes every other element.
  • You should allow a negative value for ‘step’ to count backwards. If no step is provided and the start is more than the end, assume we’re counting backwards.
  • The range should have a constructor that accepts these arguments in this order:
    1. begining index
    2. end index
    3. step interval
  • It should also support the following utility functions:
    1. size(): return the number of items represented by the range
    2. each(callback(index)): iterate over the range, passing each value to a callback function
    3. includes(index): return whether or not the range includes the passed value
  • You should also be aware of the following caveats:
    1. Should return null if we are given no ‘start’ value.
    2. Range should use constant space, even during the each() method, * i.e. you shouldnot use an array as backing storage.
USAGE EXAMPLES:
 var myRange = new Range(0,10); // a new range representing the numbers between 0 and 10 (inclusively)

 var evenNumbers = new Range(2,8,2); // A range with the even numbers 2, 4, 6, and 8.

 evenNumbers.each(function(val){ console.log(val+'!'); }); //Prints '2! 4! 6! 8!'

 evenNumbers.size() //4

 evenNumbers.includes(2) //True

 evenNumbers.include(3) //False
2. Continue pair programming on Shortly Express
I feel pretty bad for leaving early on my sprint partner. On the up-side, no more orthodontics appointments for the rest of the bootcamp!

3. Townhall (I left for the orthodontist before this)

4. Tapout

W5D1: I know Javascript



I've entered the matrix. The more I learn, the more I see things in code. I can see why Richie (friend who directed me towards this path) told me programmers feel like god. It's just a whole new world, mapped out in binary.




As I queued up for a League of Legends game, I started asking myself, "Damn, how many get and post requests are we going through to connect to this game? Just how big does the Riot (the company that made LoL) servers have to be that it hosts millions of players,  all without any significant lag?"

The more I learn at Makersquare, the more I can visualize the big picture of how technology runs this world, but at the same time, more and more questions start popping up in my head about the inner workings of tech.


I must know more! I must learn more.



What we did today:
1. Self Assessment
I don't feel too good about this one, but seeing as how hectic last week was, I feel justified

2. Lecture on Intro. to Express.js

3. Pair programming on Express
Know about bitly? It's a website that allows you to type in a URL and shortens that URL for you. We were given a partially finished, full-stack repository to work with. Using Node.js' framework called Express, our goal was to implement an authentication system and other features that will enable users to have their own private set of shortened URLs.



This sprint is very important to web development. Most sites these days require you to sign up to make an account. Naturally, authentication becomes important in protecting our users and their information.

Important takeaways for this sprint:
 -- Bcrypt is a key derivation function that takes a password, does a whole bunch of stuff to it to make it into a long hash string, which is stored inside our databases. This is important because, in the case that a hacker gets a hold of our databases, the passwords will be safe because it's indistinguishable from the actual password.
When a user logs back in, the inputted password goes through the same key derivation function, is compared to the hash in our database, and logs the user in if the two match.

 -- Sessions are used to keep users logged-in for a period of time, and not require our users to tediously log-in over and over again. This is why even though you close your Facebook tab, you are still logged in when you open FB back up again.

4. Town hall

2.8.16

Week 4 overview

This week? Yea, this week sucked. With each of the sprints this week, Makersquare threw us into a pit of fire, with no directions on how to get out. Each day I left the bookcamp feeling more clueless than the previous day. I'm going to need to go back and review backbone, node, and server side during the solo week. I hereby dub week 4 as the "hell week," and I look forward to seeing the upcoming juniors struggle on their's.


On a positive note, time seemed to have fast forwarded itself. The week went by in an instant, and my body has fully adapted to the MKS life schedule and 6 hours of sleep a day.

This week also marks the time when I picked back up an old hobby: Starcraft. If you haven't already noticed, I'm a huge gamer, and Starcraft: Brood War was the first game that I played competitively. For those who don't know, Starcraft is a real-time-strategy game that involves futuristic war between three of the most dominant races, Protoss (peace-seeking aliens), Zerg (the nasty monsters), and the Terran (the technological humans).


A Korean that plays Starcraft?? Nope, never heard of it.



I started playing again because I realized how good of a job Blizzard is doing to improve Starcraft 2's gameplay in the newest expansion, Legacy of the Void. The game has gotten a lot faster, more skill based, and more potential for hype. The expansion's predecessors, Wings of Liberty and the Heart of the Swarm, had a game design that encouraged players to turtle up in their bases, reach the max number of units, and in the end just hope your big army ball wins over the opponent's. This provided for a metagame that was stale and boring, and I quit Starcraft for good before the second expansion came out.


Legacy of the Void. It's amazing! Constant action, a lot of possibilities for micro, and the massive UI updates are what brought me back to my old habits. Feels like college all over again

#Saturday Report:

After a stressful week such as this one, I had to be inebriated. A few cohortmates took me to an American bar/club, where I awkwardly walked around without initiating talks with the females... I've been out of the game for a long time.

The music was loud, people were doing slutty things, and it just wasn't my scene. I thought... "I could be playing Starcraft right now." I took a Lyft back home and did just that.

Please help. I definitely need some advice on the science of interacting with women.

Saturday's Toy Problem:

Binary Search Array

Given a sorted array of integers, find the index of a target value using a binary search algorithm
Do NOT use Array.prototype.indexOf in your solution. What would be the fun in that?

Parameters:

array (required) - an array.

target (required) - an integer value..

W4D5: GET OUT OF MY HEAD CHARLES


A lot of my cohortmates have also noticed -- the 2 day, down, then up sprint trend.

Surely Makersquare didn't expect us to finish these ridiculous sprints without any guidance, with only the less-than-helpful videos to direct us? Surely all this is all part of their plan?

The mindgames are #real
What are you doing MKS? Why you do this?
ARE THEY DOING THIS JUST TO TORTURE US


No, Hyungki, no.

There MUST be a reason for this.

They are doing this to prepare you for the real world. We're going through a ton of these stressful  situations in the form of sprints. If we are faced with similar situations on the job, in which no one knows what the hell to do, we can take the reign because we've got this. MKS prepared us for this.

Or... it could just be MKS trolling us, and I'm just convincing myself otherwise.


What we did today:
1. Toy Problem

Tree Breadth-First Select

Implement a breadth-first method on a tree class.
BFSelect accepts a filter function, calls that function on each of the nodes in Breadth-First order, and returns a flat array of node values of the tree for which the filter returns true.
Example:
var root1 = new Tree(1);
var branch2 = root1.addChild(2);
var branch3 = root1.addChild(3);
var leaf4 = branch2.addChild(4);
var leaf5 = branch2.addChild(5);
var leaf6 = branch3.addChild(6);
var leaf7 = branch3.addChild(7);

root1.BFSelect(function (value, depth) {
  return value % 2;
}) //=> [1, 3, 5, 7]

root1.BFSelect(function (value, depth) {
  return depth === 1;
}) //=> [2, 3]
CODE TEMPLATE:
var Tree = function(value){
this.value = value;
this.children = [];
};

Tree.prototype.BFSelect = function(filter) {
var firstTime = true;
var results = [];
//Your code here

var recurse = function(node_list, depth){
if(firstTime){
firstTime = false;
if(filter(node_list.value, depth)){
results.push(node_list.value);
}
if(node_list.children){
recurse(node_list.children, depth+1);
}
}


else{
var store = [];
for(var i=0; i<node_list.length; i++){
if(filter(node_list[i].value, depth)){
results.push(node_list[i].value);
}
if(node_list[i].children){
store = store.concat(node_list[i].children);
}




}
if(store.length >0){
recurse(store, depth+1)
}
}


}


recurse(this, 0);
return results;
};

/**
* You shouldn't need to change anything below here, but feel free to look.
*/



/**
* add an immediate child
* (wrap values in Tree nodes if they're not already)
*/
Tree.prototype.addChild = function(child){
if (!child || !(child instanceof Tree)){
child = new Tree(child);
}

if(!this.isDescendant(child)){
this.children.push(child);
}else {
throw new Error('That child is already a child of this tree');
}
// return the new child node for convenience
return child;
};

/**
* check to see if the provided tree is already a child of this
* tree __or any of its sub trees__
*/
Tree.prototype.isDescendant = function(child){
if(this.children.indexOf(child) !== -1){
// `child` is an immediate child of this tree
return true;
}else{
for(var i = 0; i < this.children.length; i++){
if(this.children[i].isDescendant(child)){
// `child` is descendant of this tree
return true;
}
}
return false;
}
};

/**
* remove an immediate child
*/
Tree.prototype.removeChild = function(child){
var index = this.children.indexOf(child);
if(index !== -1){
// remove the child
this.children.splice(index,1);
}else{
throw new Error('That node is not an immediate child of this tree');
}
};


var root1 = new Tree(1);
var branch2 = root1.addChild(2);
var branch3 = root1.addChild(3);
var leaf4 = branch2.addChild(4);
var leaf5 = branch2.addChild(5);
var leaf6 = branch3.addChild(6);
var leaf7 = branch3.addChild(7);

root1.BFSelect(function (value, depth) {
return value % 2;

})
2. Reflective feedback session
I don't complain easily -- so it bothers me that with every feedback session, the volume of complaints are increasing. Most of these are legitimate complaints, but some of them are straight up baby howlings. I cringe a little inside as they go on about how their life sucks because of x and y.

One of the things I will back them up on though, are the complaints about the video lectures. The video lectures, for lack of a better word, are ass. Most of them are recordings of lectures from Hack Reactor, and they are long and stale. A good portion of each video is spent answering questions from the students, which, a lot of the times, is boring and useless information. But dang, my cohortmates were HOUNDING on the video lectures like savages... they really don't like the video lectures!

MKS, pls.

3. Lecture on Databases

3. Pair Programming on SQL + Dabases
Sprint Description: Store data persistently using the languages provided by database packages, including both traditional relational model and more recent non-relational technologies. You'll also learn to build your own ORM, a technique for shortening the gap between in-memory programs and the Database interface.

W4D4: Off-day


(literally) SIIIIIIIICK food poisoning/stomach flu. Woke up this morning to explosive diarrhea and a bit of yakking. Richard had left after waiting for me for a bit, and I promised to make his lunch for tomorrow for the inconvenience

On the plus side I got to take the day off! I spent the day catching up on my blog, reviewing what we've learned, and playing a bit lot of Starcraft.
Not good... I think I'm starting to get hooked -- ahhh, just like the good old days



What we were SUPPOSED to do today:
1. Toy Problem

Compose, Pipe


Implement the functions compose and pipe`.

Compose

Compose should return a function that is the composition of a list of functions of arbitrary length. Each function is called on the return value of the function that follows.
You can think of compose as moving right to left through its arguments.

Example

var greet = function(name){ return 'hi: ' + name;}
var exclaim = function(statement) { return statement.toUpperCase() + '!';}

var welcome = compose(greet, exclaim);
welcome('phillip'); //=> 'hi: PHILLIP!'

Pipe:

Pipe composes a series of functions and returns the resulting function. Each function is called on the return value of the preceding function.
You can think of pipe as moving left to right through its arguments.

Example

var add2 = function(number){ return number + 2; }
var multiplyBy3 = function(number){ return number * 3; }

pipe(add2, multiplyBy3)(5) //=> 21
pipe(add2, multiplyBy3, multiplyBy3)(5) //=> 63
HINT: You should use the functions reduce() and reduceRight() in your solutions.

2. Continue pair programming on Web Historian

3. Townhall

W4D3: Code-gay


Looking back at all the long lines of ugly code I wrote, I'm starting to see what "beautiful" code looks like. I can't help but to admire code written by the more experienced members of our cohort. It blows my mind how many different ways code can be written, and how elegant it can look.

One thing I've realized is that, no matter what the syntax and style of the code, conciseness and organization are two of the biggest factors that make good code, good. No one wants to sit there for hours reading line after line of code! We have to use things like modularity -- A module encapsulates related code into a single unit of code-- and recursion to keep our code short and easy to understand

.... just realized lower time-complexity is a factor too! The amount of memory the computer has to expend to run your code is very important.

Making good code is hard, and I am code-gay for all your good lookin' codes
I'm going to learn to clean the ugly off my code so I can make aspiring programmers like me code-gay for my beautiful code


What we did today:
1. Toy Problem

Function Bind


Implement the function ‘bind’, which accepts a function and a context as arguments. The context argument should override an existing context that the function is defined in. Your bind function should return the passed in function.
For example, if we have the following object:
var alice = {
  name: 'alice',
  shout: function () {
    alert('here comes' + ' ' + this.name);
  }
};

alice.shout() //=> 'here comes alice'
If you use your bind function with the context { name: 'bob' }, as is shown here:
boundShout = bind(alice.shout, { name: 'bob' })
Then calling boundShout() will alert 'here comes bob'
The following example should also work in the following way once your function is implemented:
var func = function(a, b){ return a + b };
var boundFunc = bind(func, null, 'diet');

boundFunc('coke'); //=> 'dietcoke'
Once you have finished that, implement the function ‘bind’ as a method of the Function.prototype object. This will be similar to your first solution, but should be able to be used in the following way:
var alice = {
  name: 'alice',
  shout: function () {
    alert(this.name);
  }
};

var boundShout = alice.shout.bind(alice);
boundShout(); // alerts 'alice'

boundShout = alice.shout.bind({ name: 'bob' });
boundShout(); // alerts 'bob'
DO NOT use the native bind() function in your solutions. You may use the functions call() and apply().

2. Lecture: Server side concepts

3. Video lecture: Data storage techniques

4. Pair programming on Web Historian sprint
In this sprint we were to create multiple Node services, relying on command-line server processes like Cron (a time-based background job scheduler used to schedule operating system jobs to run at fixed times) to build a duplicate of the archive.org internet archiving. Shown below is an example of what we have to make.
  • A user types in a URL
  • We check our storage if the archive for that URL exists
    • If it does, we return that archive (a snapshot of the page when it was taken)
    • If the page is not done loading, direct them to the "loading" page
    • If it doesn't, we download a snapshot of that URL page and store it in our archives
  • Write a script that will update the snapshots in our archives every minute (using CRON)




5. Townhall

02.03.16

W4D2: Harder, Faster, Stronger


Intensity: FULLY BLOWN. They're starting to dial up the difficulties of the toy problems, sprints, and self-assessments. Honestly, I've been clueless for the past few sprints. Starting from the backbone sprint I've been having a lot of trouble trying to figure out what's going on -- a good portion of the first day of each sprint was spent staring at the screen, with minimal movement in my fingers, trying to grasp the big picture of what is going on inside the files. Needless to say, it was frustrating.


As previously mentioned, I've been noticing the trend of the sprints (day 1 = despair, day 2 = relief), I I mentally prepared for this and did a better job managing my emotions during day one.

On a good note, I finally got the island count toy problem to pass! I started over on my code 3 times and took a total of 3 days to figure out this problem, I first tried to solve the problem using two for-loops, but in the end implemented the recursion algorithm that a lot of my cohortmates used. From this, I learned not to be too stubborn, especially when solving algorithm, else I'd be wasting a lot of time like I did with this particular toy problem. Learning new things everyday!



For this sprint, we were to go back to our chatterbox client and replace the remote server (which is set up through parse API) to our custom back-end server. Instead of trying to explain in my words what node.js is all about, I think it'd be better if I listed some of the important takeaways for this sprint.. because I'm still not understand a lot of server-side.


  1. Node is a library that allows you to run Javascript-written apps outside of the browser, typically in the command line
  2. Data is just a bunch of text that is transferred from/to server and client through the form of packages
  3. Since node runs locally on your computer, this means we have to install our dependencies (like underscore, jquery) directly onto our master folder through npm, a JS package manager run through the command line.
  4. Modularity and readability is maintained through exports and requires - explain more about this tomorrow!


What we did today:
1. Toy problem

Power Set

Return an array that contains the power set of a given string. The power set is a set of all the possible subsets, including the empty set.
Make sure your code does the following:
  1. All characters in a subset should be sorted alphabetically, and the array of subsets should be sorted alphabetically.
  2. Sets of the same characters are considered duplicates regardless of order and count only once, e.g. ‘ab’ and ‘ba’ are the same.
  3. Duplicate characters in strings should be ignored; for example, ‘obama’ should be evaluated as if it only contained one ‘a’. See the result below.

Examples

InputOutput
string:
"a"
[ "", "a" ]
string:
"ab"
[ "", "a", "ab", "b" ]
string:
"horse"
[ "", "e", "eh", "eho", "ehor", "ehors", "ehos", "ehr", "ehrs", "ehs", "eo", "eor", "eors", "eos", "er", "ers", "es", "h", "ho", "hor", "hors", "hos", "hr", "hrs", "hs", "o", "or", "ors", "os", "r", "rs", "s" ]
2. Continue pair programming on the node.js sprint

3. Townhall

02,02.16