This file contains 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
// Hypothetical NLP function - ES6 includes used | |
function isTextFunEnough(text) { | |
if(text.length == 0 || text.includes('angry')) | |
return false; | |
return text.includes('lol'); | |
} | |
console.log(isTextFunEnough('This article is so epic lol') ? 'Definitely fun, LMAO':'Not very funny...'); | |
// => Definitely fun, LMAO |
This file contains 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
// Using ES6 arrow functions | |
// Returns true if all even numbers doubled from @numbers are above 5 | |
function doubleEvenNumbersES6(numbers) { | |
return numbers.filter(x => x % 2 == 0).map(x => x*2).every(x => x > 5); | |
} | |
console.log(doubleEvenNumbersES6([3,4,5,6])) | |
// => True, because doubled array is [8,12] |
This file contains 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
// Using ES6 arrow functions | |
// Returns true if all even numbers doubled from @numbers are above 5 | |
function doubleEvenNumbers(numbers) { | |
return numbers | |
.filter(x => x % 2 == 0) // Odd numbers removed | |
.map(x => x*2) // Even numbers doubled | |
.every(x => x > 5); // Are they all above 5 ? | |
} |
This file contains 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
alertDialogBuilder | |
.setMessage("Click yes to exit!") | |
.setCancelable(false) | |
.setPositiveButton("Yes",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { | |
// Stuff | |
} | |
}) | |
.setNegativeButton("No",new DialogInterface.OnClickListener() { | |
public void onClick(DialogInterface dialog,int id) { |
This file contains 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 Champion(category = 'Champion') { | |
this.category = category; | |
}; | |
function Warrior() { | |
Champion.call(this,'Warrior'); | |
} | |
function Dwarf() { | |
Champion.call(this,'Dwarf'); |
This file contains 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 Champion(category = 'Champion') { | |
this.category = category; | |
this.sayHi = function() { console.log(`Hey, a ${this.category} is here`) }; | |
}; | |
function Warrior() { | |
Champion.call(this,'Warrior'); | |
} | |
function Dwarf() { |
This file contains 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
// A dead-easy data structure representing a database | |
let ArticlesDatabase = { | |
articles: [ | |
{ | |
'id': 1, | |
'title': 'Insane prank, I broke my leg watch this' | |
}, | |
{ | |
'id': 2, | |
'title': 'Cops arrested me, discover why' |
This file contains 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
// A dead-easy data structure representing a database | |
let ArticlesDatabase = { | |
content: [ | |
{ | |
'id': 1, | |
'title': 'Insane prank, I broke my leg watch this' | |
}, | |
{ | |
'id': 2, | |
'title': 'Cops arrested me, discover why' |
This file contains 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 | |
// CodeIgniter coding style with plain queries, easy to read | |
$users = $this->db->query('SELECT * FROM Users')->result(); | |
$cities = $this->db->query('SELECT * FROM Cities')->result(); | |
$usersWithCity = $this->db->query('SELECT U.*, C.city_name FROM Users U LEFT JOIN Cities C ON U.id_user = C.id_user')->result(); |
This file contains 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 | |
// Could have broken request clauses line by line | |
// SELECT X FROM Y WHERE Z | |
// -> | |
// SELECT X | |
// FROM Y | |
// WHERE Z | |
final class RequestHolder { | |
// Query a list of users without ordering |