Skip to content

Instantly share code, notes, and snippets.

View jericrealubit's full-sized avatar
🎯
Focusing

jeric realubit jericrealubit

🎯
Focusing
View GitHub Profile
@jericrealubit
jericrealubit / countSameLetterInWord.js
Last active March 1, 2024 06:20
count the word that have at least 1 same letter from other word in the sentence
// 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;
@jericrealubit
jericrealubit / arrayToCSV.js
Created November 12, 2018 02:59 — forked from yangshun/arrayToCSV.js
Converts a 2D array into a CSV file
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(','));
}
@jericrealubit
jericrealubit / Acceptance.php
Created June 7, 2018 23:10 — forked from SimonEast/Acceptance.php
Codeception - how to test for redirects
<?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
@jericrealubit
jericrealubit / datatable-alternate-stripes
Last active May 28, 2018 22:30
datatables alternate stripes
///+ 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');
@jericrealubit
jericrealubit / docker-prune.sh
Last active April 19, 2018 04:16
docker system cleanup
#!/bin/bash
#check disk space
df -h
#check dangling volume
docker volume ls -qf dangling=true
docker system prune -a --volumes
@jericrealubit
jericrealubit / docker-image-size.sh
Created April 19, 2018 02:20 — forked from andyrbell/docker-image-size.sh
Sort docker images by size desc
#!/bin/sh
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r
@jericrealubit
jericrealubit / chkASCII32_126.js
Created March 22, 2018 20:29
Validate an input string if it is inside ASCII 32 - 126 range
/**
* 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() {
@jericrealubit
jericrealubit / questions.md
Created November 9, 2017 23:59 — forked from sudomabider/questions.md
Interesting coding questions

What will it be?

Javascript

// 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;
<?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);
<?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);