Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<meta charset="utf-8" /> | |
<script src="templating.js" type="text/javascript" charset="utf-8"></script> | |
</head> | |
<body> | |
<template id=t> |
I'm not suggesting drastic action. I don't want to break backwards compatibility. I simply want to make the class
feature more usable to a broader cross section of the community. I believe there is some low-hanging fruit that can be harvested to that end.
Imagine AutoMaker contained class Car
, but the author wants to take advantage of prototypes to enable factory polymorphism in order to dynamically swap out implementation.
Stampit does something similar to this in order to supply information needed to inherit from composable factory functions, known as stamps.
This isn't the only way to achieve this, but it is a convenient way which is compatible with .call()
, .apply()
, and .bind()
.
// Bonfire: Return Largest Numbers in Arrays | |
// Author: @dbagia | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays?solution=function%20largestOfFour(arr)%20%7B%0A%20%20%2F%2F%20You%20can%20do%20this!%0A%20%20arr%20%3D%20arr.map(function(subarr)%7B%0A%20%20%20%20return%20subarr.sort(function(a%2Cb)%7B%0A%20%20%20%20%20%20return%20b%20-%20a%3B%0A%20%20%20%20%7D)%5B0%5D%3B%0A%20%20%7D)%3B%0A%20%20return%20arr%3B%0A%7D%0A%0AlargestOfFour(%5B%5B4%2C%205%2C%201%2C%203%5D%2C%20%5B13%2C%2027%2C%2018%2C%2026%5D%2C%20%5B32%2C%2035%2C%2037%2C%2039%5D%2C%20%5B1000%2C%201001%2C%20857%2C%201%5D%5D)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function largestOfFour(arr) { | |
// You can do this! | |
arr = arr.map(function(subarr){ | |
return subarr.sort(function(a,b){ | |
return b - a; |
// Bonfire: Confirm the Ending | |
// Author: @dbagia | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending?solution=function%20end(str%2C%20target)%20%7B%0A%20%20%2F%2F%20%22Never%20give%20up%20and%20good%20luck%20will%20find%20you.%22%0A%20%20%2F%2F%20--%20Falcor%0A%20%20%0A%20%20%0A%20%20return%20str.substr(-target.length)%20%3D%3D%3D%20target%3B%0A%7D%0A%0Aend(%22Bastian%22%2C%20%22n%22)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function end(str, target) { | |
// "Never give up and good luck will find you." | |
// -- Falcor | |
// Bonfire: Repeat a string repeat a string | |
// Author: @dbagia | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string?solution=function%20repeat(str%2C%20num)%20%7B%0A%20%20%2F%2F%20repeat%20after%20me%0A%20%20if(num%20%3C%201)%7B%0A%20%20%20%20return%20%22%22%3B%0A%20%20%7Delse%7B%0A%20%20%20%20return%20str.concat(repeat(str%2C%20num%20-%201))%3B%20%20%0A%20%20%7D%0A%20%20%0A%7D%0A%0Arepeat(%22abc%22%2C%203)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function repeat(str, num) { | |
// repeat after me | |
if(num < 1){ | |
return ""; | |
}else{ |
// Bonfire: Chunky Monkey | |
// Author: @dbagia | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey?solution=function%20chunk(arr%2C%20size)%20%7B%0A%20%20%2F%2F%20Break%20it%20up.%0A%20%20var%20rArr%20%3D%20%5B%5D%2C%20l%20%3D%20Math.ceil(arr.length%2Fsize)%3B%0A%0A%20%20for(var%20i%3D0%3B%20i%3Cl%3B%20i%2B%2B)%7B%0A%20%20%20%20rArr.push(arr.splice(0%2C%20size))%3B%0A%20%20%7D%0A%20%20return%20rArr%3B%0A%7D%0A%0Achunk(%5B%22a%22%2C%20%22b%22%2C%20%22c%22%2C%20%22d%22%5D%2C%202)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function chunk(arr, size) { | |
// Break it up. | |
var rArr = [], l = Math.ceil(arr.length/size); | |
for(var i=0; i<l; i++){ |
// Bonfire: Where do I belong | |
// Author: @dbagia | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong?solution=function%20where(arr%2C%20num)%20%7B%0A%20%20%2F%2F%20Find%20my%20place%20in%20this%20sorted%20array.%0A%20%20arr.push(num)%3B%0A%20%20arr.sort(function(a%2Cb)%7B%0A%20%20%20%20return%20a%20-%20b%3B%0A%20%20%7D)%3B%0A%0A%20%20return%20arr.indexOf(num)%3B%0A%7D%0A%0Awhere(%5B2%2C%205%2C%2010%5D%2C%2015)%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function where(arr, num) { | |
// Find my place in this sorted array. | |
arr.push(num); | |
arr.sort(function(a,b){ | |
return a - b; |
:r !uuidgen|sed 's/.*/"uid": "&",/' |