jiebi/CodeConvo huggingface dataset:
<SectionHeader>Privacy Settings</SectionHeader> <FullWidthRow> <p> <del> The settings in this section enable you to control what is show on{' '} </del> <ins> The settings in this section enable you to control what is shown on{' '} </ins> your freeCodeCamp public portfolio. </p> <ins> <p>There is also a button to see what data we hold on your account</p> </ins> <ToggleSetting action='Make my profile completely private' explain={
toggleFlag={ toggleFlag('showTimeLine') } /> </FullWidthRow> <ins> <FullWidthRow> <Spacer /> <Button block={true} bsSize='lg' bsStyle='primary' download={`${user.username}.json`} href={ `data:text/json;charset=utf-8,${ encodeURIComponent(JSON.stringify(user)) }` } > Download all your data </Button> </FullWidthRow> </ins> </div> ); }
"contents": [ "// Example", "var ourArray = ["Stimpson", "J", ["cat"]];", <del> "removedFromOurArray = ourArray.shift();", </del> <ins> "var removedFromOurArray = ourArray.shift();", </ins> "// removedFromOurArray now equals "Stimpson" and ourArray now equals ["J", ["cat"]].", "", "// Setup",
if (user[certType]) { const { completedChallenges = [] } = user; <del> const { completedDate = new Date() } = _.find(completedChallenges, ({ id }) => certId === id) || {}; </del> <ins> const certChallenge = _.find( completedChallenges, ({ id }) => certId === id ); let { completedDate = new Date() } = certChallenge || {}; // the challange id has been rotated for isDataVisCert // so we need to check for id 561add10cb82ac38a17513b3 if (certType === 'isDataVisCert' && !certChallenge) { console.log('olderId'); let oldDataVisIdChall = _.find( completedChallenges, ({ id }) => '561add10cb82ac38a17513b3' === id ); if (oldDataVisIdChall) { completedDate = oldDataVisIdChall.completedDate || completedDate; } } </ins> const { username, name } = user; return res.json({
} pairedWith = pairedWith.pop(); <del> //debug('This is paired with', Object.keys(pairedWith)); debug('This is paired with's uncompleted bonfires array', pairedWith.uncompletedBonfires); </del> index = pairedWith.uncompletedBonfires.indexOf(bonfireHash); if (index > -1) { pairedWith.uncompletedBonfires.splice(index,1)
}; exports.returnNextBonfire = function(req, res, next) { <del> // TODO //var tempUser = false; </del> if (!req.user) { <del> res.redirect('bonfires/meet-bonfire'); //tempUser = true; //req.user = new User(); </del> <ins> return res.redirect('bonfires/meet-bonfire'); </ins> } <del> var currentTime = parseInt(+new Date() / 1000) </del> <ins> var currentTime = parseInt(+new Date() / 1000); </ins> if (currentTime - req.user.lastContentSync > 86400) { req.user.lastContentSync = currentTime; <del> var completed = req.user.completedBonfires.map(function(elem) { </del> <ins> var completed = req.user.completedBonfires.map(function (elem) { </ins> return elem._id; }); <del> req.user.uncompletedBonfires = resources.allBonfireIds().filter(function(elem) { if (completed.indexOf(elem) === -1) { return elem; } </del> <ins> req.user.uncompletedBonfires = resources.allBonfireIds().filter(function (elem) { if (completed.indexOf(elem) === -1) { return elem; } </ins> }); req.user.save(); }
completedWith: null, title: bonfire[bonfireNumber].name, name: bonfire[bonfireNumber].name, <del> difficulty: +bonfire[bonfireNumber].difficulty, </del> <ins> difficulty: Math.floor(+bonfire[bonfireNumber].difficulty), </ins> brief: bonfire[bonfireNumber].description[0], details: bonfire[bonfireNumber].description.slice(1), tests: bonfire[bonfireNumber].tests,
"challengeEntryPoint": "meetBonfire("You can do this!");" }, { <ins> "_id": "a202eed8fc186c8434cb6d61", "name": "Reverse a String", "difficulty": "1.01", "tests": [ "expect(reverseString('hello')).to.be.a('String');", "expect(reverseString('hello')).to.equal('olleh');", "expect(reverseString('Howdy')).to.equal('ydwoH');", "expect(reverseString('Greetings from Earth')).to.equal('htraE morf sgniteerG');" ], "description": [ "Reverse the provided string.", "You may need to turn the string into an array before you can reverse it.", "Your result must be a string." ], "challengeEntryPoint": "reverseString('hello');", "challengeSeed": "function reverseString(str) {n  return str;rn}" }, { "_id": "a302f7aae1aa3152a5b413bc", "name": "Factorialize a Number", "tests": [ "expect(factorialize(5)).to.be.a("Number");", "expect(factorialize(5)).to.equal(120);", "expect(factorialize(10)).to.equal(3628800);", "expect(factorialize(20)).to.equal(2432902008176640000);" ], "difficulty": "1.02", "description": [ "Return the factorial of the provided integer.", "If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.", "Factorials are often represented with the shorthand notation n!", "For example: 5! = 1 * 2 * 3 * 4 * 5 = 120f" ], "challengeSeed": "function factorialize(num) {n  return  num;rn}", "challengeEntryPoint": "factorialize(5);" }, { </ins> "_id" : "aaa48de84e1ecc7c742e1124", "name": "Check for Palindromes", <del> "difficulty": "1", </del> <ins> "difficulty": "1.03", </ins> "description": [ "Return 'true' if a given string is a palindrome.", "A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation and case.",
.form-group label.col-sm-2.control-label.wrappable(for='description') description: .col-sm-10 <del> textarea#description.form-control(name="description", placeholder="Separate sentences by exactly one space only. Do not add in line breaks.") </del> <ins> textarea#description.form-control(name="description", rows=5, placeholder="Separate sentences by exactly one space only. Do not add in line breaks.") </ins> .form-group label.col-sm-2.control-label.wrappable(for='challengeSeed') challengeSeed: .col-sm-10
## Description <section id='description'> <del> In Computer Science a <dfn>queue</dfn> is an abstract <dfn>Data Structure</dfn> where items are kept in order. New items can be added at the back of the <code>queue</code> and old items are taken off from the front of the <code>queue</code>. </del> <ins> In Computer Science a <dfn>queue</dfn> is an abstract <dfn>Data Structure</dfn> where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue. </ins> Write a function <code>nextInLine</code> which takes an array (<code>arr</code>) and a number (<code>item</code>) as arguments. Add the number to the end of the array, then remove the first element of the array. The <code>nextInLine</code> function should then return the element that was removed.
<strong>User Story #4:</strong> When I enter GitHub flavored markdown into the <code>#editor</code> element, the text is rendered as HTML in the <code>#preview</code> element as I type (HINT: You don't need to parse Markdown yourself - you can import the Marked library for this: <a href='https://cdnjs.com/libraries/marked' target='_blank'>https://cdnjs.com/libraries/marked</a>). <strong>User Story #5:</strong> When my markdown previewer first loads, the default text in the <code>#editor</code> field should contain valid markdown that represents at least one of each of the following elements: a header (H1 size), a sub header (H2 size), a link, inline code, a code block, a list item, a blockquote, an image, and bolded text. <strong>User Story #6:</strong> When my markdown previewer first loads, the default markdown in the <code>#editor</code> field should be rendered as HTML in the <code>#preview</code> element. <del> <strong>Optional Bonus (you do not need to make this test pass):</strong> When I click a link rendered by my markdown previewer, the link is opened up in a new tab (HINT: read the Marked.js docs for this one!). </del> <strong>Optional Bonus (you do not need to make this test pass):</strong> My markdown previewer interprets carriage returns and renders them as <code>br</code> (line break) elements. You can build your project by forking <a href='http://codepen.io/freeCodeCamp/pen/MJjpwO' target='_blank'>this CodePen pen</a>. Or you can use this CDN link to run the tests in any environment you like: <code>https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js</code> Once you're done, submit the URL to your working project with all its tests passing.
```yml tests: - text: Traditional function expression should not be used. <del> testString: getUserInput => assert(!getUserInput('index').match(/function/)); </del> <ins> testString: getUserInput => assert(!removeJSComments(code).match(/function/)); </ins> - text: <code>setGear</code> should be a declarative function. <del> testString: getUserInput => assert(typeof bicycle.setGear === 'function' && getUserInput('index').match(/setGears*(.+)s*{/)); </del> <ins> testString: assert(typeof bicycle.setGear === 'function' && code.match(/setGears*(.+)s*{/)); </ins> - text: <code>bicycle.setGear(48)</code> should change the <code>gear</code> value to 48. testString: assert((new bicycle.setGear(48)).gear === 48);
## ![:rotating_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/rotating_light.png?v=3 ":rotating_light:") Intermediate Code Solution: ```javascript <del> rating = watchList.map( (item) => ({"title":item["Title"], "rating":item["imdbRating"]}) ); </del> <ins> const rating = watchList.map(item => ({title: item["Title"], rating: item["imdbRating"]})); </ins> ``` ### Code Explanation: Using ES6 notation, each item in array is processed to extract title and rating.
<ins> /** * Adapted from: * prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML * Based on https://github.com/chriskempson/tomorrow-theme * @author Rose Pritchard */ .night code[class*='language-'], .night pre[class*='language-'] { color: #ccc; font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; font-size: 1em; text-align: left; white-space: pre; word-spacing: normal; word-break: normal; word-wrap: normal; line-height: 1.5; -moz-tab-size: 4; -o-tab-size: 4; tab-size: 4; -webkit-hyphens: none; -moz-hyphens: none; -ms-hyphens: none; hyphens: none; text-shadow: none; } .night pre[class*='language-'] code[class*='language-'] { color: #d4d4d4; } /* Code blocks */ .night pre[class*='language-'] { padding: 1em; margin: 0.5em 0; overflow: auto; } .night :not(pre) > code[class*='language-'], .night pre[class*='language-'] { background: #242424; } /* Inline code */ .night :not(pre) > code[class*='language-'] { padding: 0.1em; border-radius: 0.3em; white-space: normal; } .night .token.comment, .night .token.block-comment, .night .token.prolog, .night .token.doctype, .night .token.cdata { color: #608b4e; } .night .token.punctuation { color: #ffff00; } .night .token.tag, .night .token.attr-name, .night .token.namespace, .night .token.deleted { color: #e2777a; } .night .token.function-name { color: #d4d4d4; } .night .token.boolean, .night .token.number, .night .token.function { color: #569cd6; } .night .token.property, .night .token.class-name, .night .token.constant, .night .token.symbol { color: #f8c555; } .night .token.selector, .night .token.important, .night .token.atrule, .night .token.keyword, .night .token.builtin { color: #569cd6; } .night .token.string, .night .token.char, .night .token.attr-value, .night .token.regex, .night .token.variable { color: #7ec699; } .night .token.operator, .night .token.entity, .night .token.url { color: #67cdcc; background: none; } .night .token.important, .night .token.bold { font-weight: bold; } .night .token.italic { font-style: italic; } .night .token.entity { cursor: help; } .night .token.inserted { color: green; } </ins>
section: PropTypes.string }; <del> function ChallengeDescription({ description, instructions, section }) { return ( <div className={`challenge-instructions ${section}`}> <div dangerouslySetInnerHTML={{ __html: description }} /> {instructions && ( <Fragment> <hr /> <div dangerouslySetInnerHTML={{ __html: instructions }} /> </Fragment> )} <hr /> </div> ); </del> <ins> class ChallengeDescription extends Component { componentDidMount() { // Just in case 'current' has not been created, though it should have been. if (this.instructionsRef.current) { Prism.highlightAllUnder(this.instructionsRef.current); } } constructor(props) { super(props); this.instructionsRef = React.createRef(); } render() { const { description, instructions, section } = this.props; return ( <div className={`challenge-instructions ${section}`} ref={this.instructionsRef} > <div dangerouslySetInnerHTML={{ __html: description }} /> {instructions && ( <Fragment> <hr /> <div dangerouslySetInnerHTML={{ __html: instructions }} /> </Fragment> )} <hr /> </div> ); } </ins> } ChallengeDescription.displayName = 'ChallengeDescription';
## Description <section id='description'> <del> To create a CSS Variable, you just need to give it a <code>name</code> with <code>two dashes</code> in front of it and assign it a <code>value</code> like this: </del> <ins> To create a CSS variable, you just need to give it a <code>name</code> with <code>two dashes</code> in front of it and assign it a <code>value</code> like this: </ins> ```css --penguin-skin: gray;
## Instructions <section id='instructions'> <del> In the <code>penguin</code> class, create a variable name <code>--penguin-skin</code> and give it a value of <code>gray</code> </del> <ins> In the <code>penguin</code> class, create a variable name <code>--penguin-skin</code> and give it a value of <code>gray</code>. </ins> </section> ## Tests
--- title: Caesars Cipher --- <del> ![:triangular_flag_on_post:](https://forum.freecodecamp.com/images/emoji/emoji_one/triangular_flag_on_post.png?v=3 ":triangular_flag_on_post:") Remember to use <a>**`Read-Search-Ask`**</a> if you get stuck. Try to pair program ![:busts_in_silhouette:](https://forum.freecodecamp.com/images/emoji/emoji_one/busts_in_silhouette.png?v=3 ":busts_in_silhouette:") and write your own code ![:pencil:](https://forum.freecodecamp.com/images/emoji/emoji_one/pencil.png?v=3 ":pencil:") ### ![:checkered_flag:](https://forum.freecodecamp.com/images/emoji/emoji_one/checkered_flag.png?v=3 ":checkered_flag:") Problem Explanation: *   You need to write a function, which will take a string encoded with _Caesar cipher_ as a parameter and decode it. *   The one used here is ROT13 where the value of the letter is shifted by 13 places. e.g. 'A' ![:left_right_arrow:](https://forum.freecodecamp.com/images/emoji/emoji_one/left_right_arrow.png?v=3 ":left_right_arrow:") 'N', 'T' ![:left_right_arrow:](https://forum.freecodecamp.com/images/emoji/emoji_one/left_right_arrow.png?v=3 ":left_right_arrow:") 'G'. *   You have to shift it back 13 positions, such that 'N' ![:left_right_arrow:](https://forum.freecodecamp.com/images/emoji/emoji_one/left_right_arrow.png?v=3 ":left_right_arrow:") 'A'. #### Relevant Links *   <a href='http://forum.freecodecamp.com/t/javascript-string-prototype-charcodeat/15933' target='_blank' rel='nofollow'>String.prototype.charCodeAt</a> *   <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode' target='_blank' rel='nofollow'>String.fromCharCode</a> </del> ## ![:speech_balloon:](https://forum.freecodecamp.com/images/emoji/emoji_one/speech_balloon.png?v=3 ":speech_balloon:") Hint: 1
## ![:beginner:](https://forum.freecodecamp.com/images/emoji/emoji_one/beginner.png?v=3 ":beginner:") Basic Code Solution: ```javascript <del> function rot13(str) { // Split str into a character array return str.split('') // Iterate over each character in the array .map.call(str, function(char) { // Convert char to a character code x = char.charCodeAt(0); // Checks if character lies between A-Z if (x < 65 || x > 90) { return String.fromCharCode(x);  // Return un-converted character } //N = ASCII 78, if the character code is less than 78, shift forward 13 places else if (x < 78) { return String.fromCharCode(x + 13); } // Otherwise shift the character 13 places backward return String.fromCharCode(x - 13); }).join('');  // Rejoin the array into a string } </del> <ins> function rot13(str) { // Split str into a character array return str.split('') // Iterate over each character in the array .map.call(str, function(char) { // Convert char to a character code var x = char.charCodeAt(0); // Checks if character lies between A-Z if (x < 65 || x > 90) { return String.fromCharCode(x);  // Return un-converted character } //N = ASCII 78, if the character code is less than 78, shift forward 13 places else if (x < 78) { return String.fromCharCode(x + 13); } // Otherwise shift the character 13 places backward return String.fromCharCode(x - 13); }).join('');  // Rejoin the array into a string } </ins> ``` <del> ![:rocket:](https://forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=3 ":rocket:") <a href='https://repl.it/CLjU/38' target='_blank' rel='nofollow'>Run Code</a> </del> ### Code Explanation:
#### Relevant Links <del> *   <a href='http://forum.freecodecamp.com/t/javascript-array-prototype-map/14294' target='_blank' rel='nofollow'>Array.prototype.map</a> *   <a href='http://forum.freecodecamp.com/t/javascript-string-prototype-split/15944' target='_blank' rel='nofollow'>String.prototype.split</a> *   <a href='http://forum.freecodecamp.com/t/javascript-array-prototype-join/14292' target='_blank' rel='nofollow'>Array.prototype.join</a> </del> <ins> *   <a href='https://forum.freecodecamp.com/t/javascript-array-prototype-map/14294' target='_blank' rel='nofollow'>Array.prototype.map</a> *   <a href='https://forum.freecodecamp.com/t/javascript-string-prototype-split/15944' target='_blank' rel='nofollow'>String.prototype.split</a> *   <a href='https://forum.freecodecamp.com/t/javascript-array-prototype-join/14292' target='_blank' rel='nofollow'>Array.prototype.join</a> </ins> ## ![:sunflower:](https://forum.freecodecamp.com/images/emoji/emoji_one/sunflower.png?v=3 ":sunflower:") Intermediate Code Solution: ```javascript <del> // Solution with Regular expression and Array of ASCII character codes function rot13(str) { var rotCharArray = []; var regEx = /[A-Z]/ ; str = str.split(""); for (var x in str) { if (regEx.test(str[x])) { // A more general approach // possible because of modular arithmetic // and cyclic nature of rot13 transform rotCharArray.push((str[x].charCodeAt() - 65 + 13) % 26 + 65); } else { rotCharArray.push(str[x].charCodeAt()); } } str = String.fromCharCode.apply(String, rotCharArray); return str; </del> <ins> // Solution with Regular expression and Array of ASCII character codes function rot13(str) { var rotCharArray = []; var regEx = /[A-Z]/; str = str.split(""); for (var x in str) { if (regEx.test(str[x])) { // A more general approach // possible because of modular arithmetic // and cyclic nature of rot13 transform rotCharArray.push((str[x].charCodeAt() - 65 + 13) % 26 + 65); } else { rotCharArray.push(str[x].charCodeAt()); </ins> } <ins> } str = String.fromCharCode.apply(String, rotCharArray); return str; } </ins> <del> // Change the inputs below to test rot13("LBH QVQ VG!"); </del> <ins> // Change the inputs below to test rot13("LBH QVQ VG!"); </ins> ``` ### Code Explanation:
*   <a href='https://forum.freecodecamp.com/t/regular-expressions-resources/15931' target='_blank' rel='nofollow'>Regex</a> *   <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test' target='_blank' rel='nofollow'>Regex.test</a> <del> ![:rocket:](https://forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=3 ":rocket:") <a href='https://repl.it/CLjU/39' target='_blank' rel='nofollow'>Run Code</a> </del> ## ![:rotating_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/rotating_light.png?v=3 ":rotating_light:") Advanced Code Solution: function rot13(str) { // LBH QVQ VG!
Editor.displayName = 'Editor'; Editor.propTypes = propTypes; <ins> // NOTE: withRef gets replaced by forwardRef in react-redux 6, // https://github.com/reduxjs/react-redux/releases/tag/v6.0.0 </ins> export default connect( mapStateToProps, <del> mapDispatchToProps </del> <ins> mapDispatchToProps, null, { withRef: true } </ins> )(Editor);
e.preventDefault(); if (executeChallenge) executeChallenge(); }, <ins> FOCUS_EDITOR: e => { e.preventDefault(); if (editorRef && editorRef.current) { editorRef.current.getWrappedInstance().focusOnEditor(); } }, </ins> NAVIGATION_MODE: () => setEditorFocusability(false), NAVIGATE_PREV: () => { if (!canFocusEditor) navigate(prevChallengePath);
} } <ins> function replacer(key, value) { if (Number.isNaN(value)) { return 'NaN'; } return value; } </ins> const oldLog = self.console.log.bind(self.console); self.console.log = function proxyConsole(...args) { <del> logs.push(args.map(arg => '' + JSON.stringify(arg)).join(' ')); </del> <ins> logs.push(args.map(arg => '' + JSON.stringify(arg, replacer)).join(' ')); </ins> if (logs.join('n').length > MAX_LOGS_SIZE) { flushLogs(); }
- text: Your code should use the <code>filter</code> method. testString: assert(code.match(/.filter/g)); - text: Your code should not use a <code>for</code> loop. <del> testString: assert(!code.match(/fors*?(.+?)/g)); </del> <ins> testString: assert(!code.match(/fors*?([sS]*?)/g)); </ins> - text: '<code>filteredList</code> should equal <code>[{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]</code>.' testString: 'assert.deepEqual(filteredList, [{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]);'
- text: The <code>watchList</code> variable should not change. testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron"); - text: Your code should not use a <code>for</code> loop. <del> testString: assert(!removeJSComments(code).match(/fors*?(.*?)/)); </del> <ins> testString: assert(!removeJSComments(code).match(/fors*?([sS]*?)/)); </ins> - text: Your code should use the <code>map</code> method. testString: assert(code.match(/.map/g)); - text: <code>ratings</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.
- text: The <code>getRating(watchList)</code> should equal 8.675. testString: assert(getRating(watchList) === 8.675); - text: Your code should not use a <code>for</code> loop. <del> testString: assert(!code.match(/fors*?(.*)/g)); </del> <ins> testString: assert(!code.match(/fors*?([sS]*?)/g)); </ins> - text: Your code should return correct output after modifying the <code>watchList</code> object. testString: assert(getRating(watchList.filter((_, i) => i < 1 || i > 2)) === 8.55);
A strategy is a way of authenticating a user. You can use a strategy for allowing users to authenticate based on locally saved information (if you have them register first) or from a variety of providers such as Google or GitHub. For this project, we will set up a local strategy. To see a list of the hundreds of strategies, visit Passport's site [here](http://passportjs.org/). <del> Add `passport-local` as a dependency and add it to your server as follows: `const LocalStrategy = require('passport-local');` </del> <ins> Add `passport-local@~1.0.0` as a dependency and add it to your server as follows: `const LocalStrategy = require('passport-local');` </ins> Now you will have to tell passport to **use** an instantiated LocalStrategy object with a few settings defined. Make sure this (as well as everything from this point on) is encapsulated in the database connection since it relies on it!