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
| // Naive utility method | |
| function getRandomNumber(min, max){ | |
| return Math.floor(Math.random() * (max - min + 1)) + min; | |
| } | |
| getRandomNumber(15, 20); | |
| // Lodash | |
| _.random(15, 20); |
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 rockets = [ | |
| { country:'Russia', launches:32 }, | |
| { country:'US', launches:23 }, | |
| { country:'China', launches:16 }, | |
| { country:'Europe(ESA)', launches:7 }, | |
| { country:'India', launches:4 }, | |
| { country:'Japan', launches:3 } | |
| ]; |
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
| 'b' + 'a' + + 'a' + 'a' // "baNaNa" |
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
| function param(object) { | |
| var encodedString = ''; | |
| for (var prop in object) { | |
| if (object.hasOwnProperty(prop)) { | |
| if (encodedString.length > 0) { | |
| encodedString += '&'; | |
| } | |
| encodedString += encodeURI(prop + '=' + object[prop]); | |
| } | |
| } |
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 xhr = new XMLHttpRequest(); | |
| xhr.open('PUT', 'myservice/user/1234'); | |
| xhr.setRequestHeader('Content-Type', 'application/json'); | |
| xhr.onload = function() { | |
| if (xhr.status === 200) { | |
| var userInfo = JSON.parse(xhr.responseText); | |
| } | |
| }; | |
| xhr.send(JSON.stringify({ | |
| name: 'John Smith', |
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 str = "5359999999"; | |
| var patt = new RegExp("(05|5)[0-9][0-9][1-9]([0-9]){6}"); | |
| var res = patt.test(str); | |
| console.log(res); // true |
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
| <?php | |
| /* | |
| * Mysql database class - only one connection alowed | |
| */ | |
| class Database { | |
| private $_connection; | |
| private static $_instance; //The single instance | |
| private $_host = "HOSTt"; | |
| private $_username = "USERNAME"; | |
| private $_password = "PASSWORd"; |
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 d = new Date(); | |
| var seconds = Math.round(d.getTime() / 1000); // 10 digit | |
| // Same as moment.js | |
| moment().unix(); | |
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 dd = [ | |
| {"classroom_fk":9,"classroom_name":"9. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":10,"classroom_name":"10. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":11,"classroom_name":"11. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":11,"classroom_name":"11. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":11,"classroom_name":"11. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":12,"classroom_name":"12. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":12,"classroom_name":"12. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":12,"classroom_name":"12. Sınıf","maxLicenceNumber":100,"licenceCount":6,"pointtype_related":true}, | |
| {"classroom_fk":10,"classroom_name":"10. Sınıf","maxLicenceNumber":100,"licen |
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
| #add 'node_modules' to .gitignore file | |
| git rm -r --cached node_modules | |
| git commit -m "Remove the now ignored directory node_modules" | |
| git push origin master |