This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arrayOfWords = ['the', 'quick', 'brown', 'fox']; | |
| for (let i = 0; i < arrayOfWords.length; i += 1) { | |
| arrayOfWords[i] = arrayOfWords[i][0].toUpperCase() + arrayOfWords[i].slice(1); | |
| } | |
| console.log(arrayOfWords); // ["The", "Quick", "Brown", "Fox"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $data = array("name" => "James", "age" => "36"); | |
| $data_string = json_encode($data); | |
| $ch = curl_init('http://localhost/post.php'); | |
| curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
| 'Content-Type: application/json', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let pp = this.proposalForm; | |
| let $datefields = $('.date input').datepicker( | |
| { | |
| format: "dd/mm/yyyy" | |
| } | |
| ); | |
| $datefields.on('changeDate', function (e) { | |
| let fcn = $(this).attr('formControlName'); | |
| let index = e; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var parse_params = function(url){ | |
| var pairs = url.match(/\/?\??(.*)/)[1].split('&'); | |
| var out = []; | |
| pairs.forEach(function(chunk){ | |
| var keyvalues = chunk.split('='); | |
| for(var i=0; i<keyvalues.length; i++){ | |
| if(i % 2 === 0){ | |
| var obj = {}; | |
| obj[keyvalues[i]] = keyvalues[i + 1] | |
| out.push(obj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var sqlite3 = require('sqlite3').verbose(); | |
| var get_rows = function(query, callback){ | |
| var db = new sqlite3.Database('test.db'); | |
| db.serialize(function(){ | |
| db.all(query, function(err, rows){ | |
| callback(rows); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Make sure the mail gem is available first: | |
| # gem install mail | |
| require 'mail' | |
| Mail.defaults do | |
| delivery_method :smtp, { | |
| :port => 465, # Change this if your provider requires a different port for SSL | |
| :address => "<yourSMTPServer>", | |
| :user_name => "<yourUserName>", | |
| :password => "<yourPassword>", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Everything Be True | |
| // Author: @codebubb | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-everything-be-true | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function every(collection, pre) { | |
| // Is everyone being true? | |
| return collection.every(function(e){ | |
| return Object.keys(e).indexOf(pre) !== -1 && e[pre]; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Binary Agents | |
| // Author: @codebubb | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-binary-agents | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function binaryAgent(str) { | |
| return str.split(' ').map(function(e){ | |
| return String.fromCharCode(parseInt(e, 2)); | |
| }).reduce(function(a,b){ | |
| return a+b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Steamroller | |
| // Author: @codebubb | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-steamroller | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function steamroller(arr) { | |
| var flattened = []; | |
| function flatten(a){ | |
| return Array.isArray(a) ? a.forEach(flatten) : flattened.push(a); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Smallest Common Multiple | |
| // Author: @codebubb | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-smallest-common-multiple# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function smallestCommons(arr) { | |
| var nums = range(arr[0], arr[1]); | |
| return nums.reduce(lcm); | |
| } |