// Without running these in the browser, can you tell what each of the following would return?
['1', '2', '3', '4'].map(parseInt);
(new Array(2)).map(function() {
return 1;
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
// count the word that have at least 1 same letter from other word in the sentence, | |
// will check letters only special characters will be ignored | |
function countSameLetterInWord(sentence) { | |
// remove special characters from the input | |
let input = sentence.replace(/[^a-zA-Z ]/g, ""); | |
//console.log(input); | |
let words = input.split(" "); | |
let tempWords; | |
let tempLetter; |
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 arrayToCSV (twoDiArray) { | |
// Modified from: http://stackoverflow.com/questions/17836273/ | |
// export-javascript-data-to-csv-file-without-server-interaction | |
var csvRows = []; | |
for (var i = 0; i < twoDiArray.length; ++i) { | |
for (var j = 0; j < twoDiArray[i].length; ++j) { | |
twoDiArray[i][j] = '\"' + twoDiArray[i][j] + '\"'; // Handle elements that contain commas | |
} | |
csvRows.push(twoDiArray[i].join(',')); | |
} |
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 | |
// Simply place the following two functions in _support/Helper/Acceptance.php | |
// Then you can call $I->verifyRedirect(...) inside your tests | |
namespace Helper; | |
class Acceptance extends \Codeception\Module | |
{ | |
/** | |
* Ensure that a particular URL does NOT contain a 301/302 |
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
///+ Service Type Stripe | |
var cnt = 0; | |
$('td:first-child').each(function() { | |
if ($(this).text() != '') { | |
cnt++; | |
if (cnt % 2 == 0) { | |
var oTR = $(this).parent(); | |
if (oTR.attr('class') == 'odd') { | |
var nx = oTR.css('background-color','#faf6e6'); |
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
#!/bin/bash | |
#check disk space | |
df -h | |
#check dangling volume | |
docker volume ls -qf dangling=true | |
docker system prune -a --volumes |
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
#!/bin/sh | |
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r |
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
/** | |
* Validate an input string if it is inside ASCII 32 - 126 range | |
* @param string | |
* @return true if all characters in the string are in range, else false | |
*/ | |
var chkASCII32_126 = function(string) { | |
return !string.match(/[^\x20-\x7e]/g); | |
} | |
$(".chorusASCIIValidation").keyup(function() { |
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 | |
require_once __DIR__ . '/vendor/autoload.php'; | |
use PhpAmqpLib\Connection\AMQPStreamConnection; | |
$connection = new AMQPStreamConnection('jeric.devel.nz', 5672, 'guest', 'guest'); | |
$channel = $connection->channel(); | |
$channel->queue_declare('hello', false, false, false, false); |
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 | |
require_once __DIR__ . '/vendor/autoload.php'; | |
use PhpAmqpLib\Connection\AMQPStreamConnection; | |
use PhpAmqpLib\Message\AMQPMessage; | |
$connection = new AMQPStreamConnection('jeric.devel.nz', 5672, 'guest', 'guest'); | |
$channel = $connection->channel(); | |
$channel->queue_declare('hello', false, false, false, false); |
NewerOlder