freecodecampofdespair-blog
freecodecampofdespair-blog
good technology job
19 posts
join me in my acceptance that I will never make money building websites as a profession whilst pushing myself through the Free Code Camp, a bootcamp-style free educational coding curriculum. 
Don't wanna be here? Send us removal request.
freecodecampofdespair-blog · 10 years ago
Text
LearnYouNode Challenge 10: HTTP JSON API SERVER
know I kinda gave up on this, but I’ve not given up on FCC. just finished learnyounode exercise 10 and upon seeing the solution provided, I don’t understand why it’s so complicated. Instead of regexing take a look at this:
var http = require('http'); var url = require('url');
var server = http.createServer(function(req, res){
var reqObj = url.parse(req.url, true); var timeHolder = reqObj.query.iso; var time = new Date(timeHolder); var retObj = {};
res.writeHead(200, { 'Content-Type': 'application/json' });
if (reqObj.pathname === '/api/parsetime'){ retObj.hour = time.getHours(); retObj.minute = time.getMinutes(); retObj.second = time.getSeconds(); res.end(JSON.stringify(retObj)); } else if (reqObj.pathname === '/api/unixtime'){  retObj.unixtime = time.getTime();  res.end(JSON.stringify(retObj)); } else { console.log('woops!');}
}); server.listen(process.argv[2]);
2 notes · View notes
freecodecampofdespair-blog · 10 years ago
Link
here’s something instructional I made
0 notes
freecodecampofdespair-blog · 10 years ago
Link
Reverse engineering really isn’t the term here. Although I wish I had used an API (seeing that from here out probably everything will use an API) this was like 4 lines of jQuery/js. I suppose the correct thing to do would be to store quotes and authors in the same array, split the array and w/e but because I don’t follow rules and live for shortcuts/the easy route & because I find quotes to be just slightly less vapid than poems, I decided to go with two arrays of shit-quotes and authors, randomly assigning one to another. the jquery is pretty easy 2 figure out. select your button, on click run a function that selects your quote id and your author id and replaces them with this entry in your array after applying Math.floor(Math.random() * (max - min + 1)) + min; so u get a randomly selected number from your max which u can just hard code as the amount of entries and your min (0). I did two separately because I’m lazy and don’t care.
The twitter link was by far the most difficult part. I had made a custom button from twitters website and was trying my damnest to dynamically change it’s anchor data-text property but I guess it’s impossible? googled it and found a way to assign text with uri in a href link. I don’t know if those terms mean anything together but I got it 2 work & that’s what counts.
0 notes
freecodecampofdespair-blog · 10 years ago
Link
Generally speaking, the majority of this design relies on poorly customized bootstrap based gridding. If you understand the grid system and classes, IDs, etc. then you’re good2go. Created a bunch of divs at 100vh (codepen doesn’t auto-enable meta:vp I believe, so make sure and click that in html settings), used some anchors for inline ul nav links & then pasted bootstrap sample navbar and worked some css majick. got caught up on the hamburger menu for 30 minutes or so: make sure 2 enable both bootstrap css & js individually w/ codepen css & js properties...
Fontawesome social glyphs aren’t included in bootstrap so u gotta link those if you’re gonna use them. Everything else involved is pretty mundane and repetitive. Mostly proud of my sweet gif logo although it’s got 2 b unimaginably bad 4 load time. Worth it tho- look at that perfectly round 1 pixel solid black border- mmm. everything else is screenpuke
1 note · View note
freecodecampofdespair-blog · 10 years ago
Text
Whoo!
Got a little carried away now that I am doing nothing with my life. Sped thru the last couple bonfires and have begun Ziplining fwiw.
I’ll post about each one and a general idea of what I did.
0 notes
freecodecampofdespair-blog · 10 years ago
Text
my b on quitting like one day in- have been in the process of getting fired from my job at america’s current favorite employer, Amazon, and had originally just planned to wait for the next bunch of html/css exercises to be posted. Hoping to work on some bonfires tomorrow and do plan to continue explaining my answers, as my employment permits. Got two interviews for jobs having nothing to do with computers whatsoever this week so wish me luck and dog bless
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Falsey Bouncer
Difficulty Level: 1- tedious is as tedious as is tedious as 
My Solution:
function bouncer(arr) {  // Don't show a false ID to this bouncer.  function defalsify(id) {    if (id) {return true;}    else {return false;}  }
 return arr.filter(defalsify); }
Create a callback function inside the bouncer function that does a boolean check of the id as a non-false value. Return the applied function as a filter on the array passed in to the bouncer function. 
Tried 2 do this one using a for loop just to see if I could, and it turns out I cannot.
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Mutations
Difficulty Level: 1 dead star
My Solution:
function mutation(arr) {  var one = arr[0].toLowerCase(); //"floor"  var two = arr[1].toLowerCase().split(""); //"f","o","r"  for (var i = 0;i<arr[1].length;i++){ //3 iterations  if (one.indexOf(two[i]) === -1)  {return false;}
 }  return true; }
Set two variables, one string- equal to lowercase equivalent of your larger word; one matrix containing each individual letter, lowercase, of the smaller comparative word. Iterate through your array for as many times as there are letters in the comparative word and use an if statement to check if the indexOf values are set to -1, indicating that the letter is in fact not found within the larger word. If any value triggers the if statement, return false that the specific letter cannot be found, otherwise return true.
The later it gets in the evening, the more likely these posts are going to become more sporadic and error-prone - fyi.
0 notes
freecodecampofdespair-blog · 10 years ago
Link
0 notes
freecodecampofdespair-blog · 10 years ago
Link
Here’s a link to my profile. If you are interested in pair programming or otherwise want to contact me, I have enabled /ask.
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Slasher Flick
Difficulty Level: 1 night 2 speed up truth
My Solution:
function slasher(arr, howMany) {  // it doesn't always pay to be first  arr = arr.slice(howMany,arr.length);  return arr; }
Set the array equal to a slice of itself from howMany to the end of the array, then return the array.
Couldn't be easier than this.
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Chunky Monkey
Difficulty Level: 1, maybe use ur head?
My Solution:
function chunk(arr, size) {  // Break it up.  var newarr =[];  var secondarr=[];  var temp = 0;  while (temp < arr.length) {    newarr = arr.slice(temp, temp + size);    secondarr.push(newarr);    temp = temp + size;  }  arr = secondarr;  return arr; }
Set up two temporary arrays- one as a placeholder for the values taken out of your original array, then one as a placeholder for the arrays you will create. Also set a counter variable- not sure why I went with “temp.” Execute a while statement that will iterate through slices of your previous array from temp, what is initially the zero index of your function, to the size variable inputted, then set the temp variable to equal itself plus size to move to the next sliceable matrix from your initial array. Push this array into your container array, secondarr, in my solution. Last step- set your initial array equal to your container array.
Lots of bad naming conventions on my part in this exercise. If it were something important I’d camelcase and think a tiny bit harder about variable names. Still not sure if returning the original “arr” back is necessary- maybe I’m unnecessarily abstracting things? are you maybe not supposed to worry about it and just put whatever you want in your return statement? 
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Truncate a string
Difficulty Level: 1, codeacademy stuff, c’mon
My Solution:
function truncate(str, num) {  // Clear out that junk in your trunk  if (str.length>num) {  str = str.slice(0,num-3) + "...";  }  return str; }
Check to see that the string is, in fact, larger than the allowed number of characters. If this is the case, set str equal to a slice of itself starting at index 0 and ending at the given num minus the three character spaces reserved for the ellipses. Otherwise, return the string as you would normally.
Where’s a good retail chain to buy discount chinese-made sunglasses?
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Repeat a string repeat a string
Difficulty Level: 1, h8 u
My Solution:
function repeat(str, num) {  // repeat after me  if (num>0)    {str = str.repeat(num);}  else    {str = "";}
 return str; }
Use an if statement to determine that your integer value num is greater than zero, if it is, set str to equal to an invocation of its repeat function num many times . If num is equal to zero or less, set str equal to “” and return the string.
 Be thankful .repeat is part of the string object prototype- no need to reinvent the wheel and end up in concatenation hell.
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Confirm the Ending
Difficuly Level: 1, this one barely warrants that.
My Solution:
function end(str, target) {  // "Never give up and good luck will find you."  // -- Falcor  var a = target.length;  var b = str.length;  if (str.substr(b-a) != target){    str= false;  }  else    str= true;  return str; }
Set two variables, respectively to the lengths of both the string and the target substring. In an if statement, compare the substring with a start at the indices of your second variable, the length of the string, minus the length of your target, giving you the ending portion, and when compared to the original inputted value, if the results do not match: set str to false, otherwise set str to true and return the str. 
Logic wise, I kinda pretzeled this one a little- mostly to adhere to the format of returning the variable str, albeit not originally, as a boolean value. Don’t know why I used != either. Also, I know my JS boolean game is :( 'coz I don’t remember those cool shortcuts with the question marks and pipes and colons. 
0 notes
freecodecampofdespair-blog · 10 years ago
Text
Bonfire: Return Largest Numbers in Arrays
Difficulty Level: 1 lighter scrape, you pathetic fake
My Solution:
function largestOfFour(arr) {  // You can do this!  var num = 0;  for (var i = 0; i <arr.length; i++)    {      var temp = arr[i];      for (var j = 0; j<temp.length;j++) {       if (temp[j] > num) {num=temp[j];}        }      arr[i] = num;    }  return arr; }
First, use two for loops, one iterating through your main array, then one to iterate through sub-arrays. In your encapsulated for loop, set up a temp variable for both your highest number and references to the arrays so that you can make an if comparison that will return the highest number as an integer back into your original array. Rereading this, it was a mistake to declare the var num = 0 globally, in that if the arrays fed in had not been arranged to increase in value in each subsequent array, the num variable would have remained at the maximum of the highest array.
Longing to see the new JS, HTML and CSS stuff added next week (?) or w/e. hope it is less repetitive and sophomorish “basics of CS and OOP”-tier
0 notes
freecodecampofdespair-blog · 10 years ago
Link
0 notes