Skip to content

Instantly share code, notes, and snippets.

function palindrome(str) {
var punct = str.replace(/[.,-\/#!$%\^&\*;:{}=\-_`~()]/g, "").split(' ').join('').toLowerCase();
var string = punct.split('').reverse().join('').replace(/[.,-\/#!$%\^&\*;:{}=\-_`~()]/g, "");
if (punct == string) {
return true;
}
else {
return false;
}
}
@mp3063
mp3063 / read-ms-office.php
Created February 11, 2017 20:10
extract text from doc, docx, xlsx and pptx files
class DocxConversion{
private $filename;
public function __construct($filePath) {
$this->filename = $filePath;
}
private function read_doc() {
$fileHandle = fopen($this->filename, "r");
$line = @fread($fileHandle, filesize($this->filename));
@mp3063
mp3063 / Countdown
Created February 13, 2017 01:14
Simple countdown timer
var count=30;
var counter=setInterval(timer, 1000); //1000 will run it every 1 second
function timer()
{
count=count-1;
if (count <= 0)
{
clearInterval(counter);
@mp3063
mp3063 / jquery_contains_fix_caseinsensitive.js
Created March 21, 2017 21:44
Work around to get case insensitive search with jquery :contains method
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
return function( elem ) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
@mp3063
mp3063 / CaseInsensitiveContains.js
Last active May 9, 2017 14:50
Work around to get case insensitive :contains. Example search element like on packagist. Show searched elements and hide others.
$(".search-song").keyup(function () {
// work around to get case insensitive :contains
$.expr[":"].contains = $.expr.createPseudo(function (arg) {
return function (elem) {
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
};
});
let searchSongValue = $(this).val();
let songField = $(".song");
let findSong = $(".song:contains('" + searchSongValue + "')").show();
@mp3063
mp3063 / cept.bat
Created May 20, 2017 12:33
Make this file and than run cept bootstrap to scaffold codeception folders for tests on windows.
@echo off
@setlocal
set CODECEPT_PATH=vendor/bin/
"%CODECEPT_PATH%codecept.bat" %*
@endlocal
@mp3063
mp3063 / hide_iframe.css
Created February 23, 2018 14:09
Hide google translate iframe
.goog-te-banner-frame.skiptranslate {
display: none !important;
}
body {
top: 0px !important;
}
@mp3063
mp3063 / shortenTextWithMoreLessLinks.js
Created March 16, 2018 12:16
Toggle text more than 100 characters hide and show more link btn, on click show whole text adn less btn
@mp3063
mp3063 / change_encoding.rb
Last active September 26, 2018 22:02
Change encoding of .dat file and split by lines #rails #encoding
open(url, "r:ISO-8859-1:UTF-8").each_line
@mp3063
mp3063 / rake_task_example.rake
Last active September 26, 2018 22:00
Rake task example #rails #rake
require_relative '../../app/matko/nokogiri_scrape.rb'
namespace :shipment do
desc('Check if there any changes in shipments')
task schedule: :environment do
nok = NokogiriScrape.new
nok.check_all_shipments
end
end