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
// import `thirdPartyFunction` as a member of the imported module | |
import * as myDependency from 'my-dependency' | |
export default myTestableFunction(arg1) { | |
// and call `thirdPartyFunction` as a member of the imported module | |
myDependency.thirdPartyFunction(arg1) | |
} |
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
module.exports = function () { | |
this.verse = (n) => { | |
const otw = 'on the wall' | |
const numNow = n === 0 ? 'no more' : n | |
const itOne = numNow < 2 ? 'it' : 'one' | |
const numAfter = ((n - 1) < 0) ? 99 : ((n - 1) === 0) ? 'no more' : n - 1 | |
return [ | |
`${cap(numNow)} ${bottle(n)} ${otw}, `, |
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 visitCount = 10000; | |
var touches = 0; | |
var seatDown = true; | |
/** | |
* The "Seat-Down" policy | |
* | |
* - Each user places the seat down after conducting | |
* his or her business. |
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 http = require('http'); | |
function async(url, next) { | |
// Log for demo purposes - remove | |
console.log('url: ', url); | |
http.get(url, function (res) { | |
// setTimeout for demo purposes - remove | |
setTimeout(function () { | |
next(res.statusCode); |
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 which = event.which; // or whatever defines `which` | |
var chars = [1, 2, 3, 4]; | |
if (iPressedOneOfThese(chars)) { | |
// Do my stuff | |
} | |
function iPressedOneOfThese(array) { | |
array.filter(chars, function (char) { | |
return which === char; |
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
while ($row = $result->fetch_assoc()) { | |
print_r($row); | |
echo $row['email']; | |
} |
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
// Performs a database query using PHP's MYSQLI class | |
// Returns a result object if successful | |
// Else dies and displays the SQL error and the query string that failed | |
function db_query($mysqli, $sql) { | |
$result = $mysqli->query($sql); | |
if (!$result) { | |
$message = "SQL error: ".$mysqli->errno." ".$mysqli->error.'<br>'; |