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
# Use the following ghostscript command: | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook \ | |
-dNOPAUSE -dQUIET -dBATCH -sOutputFile=/home/niketpathak/Downloads/output.pdf /home/niketpathak/Downloads/input.pdf | |
# Summary of -dPDFSETTINGS: | |
# -dPDFSETTINGS=/screen lower quality, smaller size. (72 dpi) | |
# -dPDFSETTINGS=/ebook for better quality, but slightly larger pdfs. (150 dpi) | |
# -dPDFSETTINGS=/prepress output similar to Acrobat Distiller "Prepress Optimized" setting (300 dpi) | |
# -dPDFSETTINGS=/printer selects output similar to the Acrobat Distiller "Print Optimized" setting (300 dpi) |
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
# Get the process ID of the process running on port xyz | |
lsof -i -P -n | grep xyz # xyz is the desired port number | |
# Force kill the process running on the port by providing the process ID you find from the above statement | |
kill -9 processID | |
# if you have npm/npx | |
npx kill-port portNumber | |
#### More info on lsof #### |
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 | |
echo generateExcerpt('Some long text is not really present here', 15); // Some long... | |
/** | |
* Generate an Excerpt for a given String | |
* @param string $content The content | |
* @param int $maxLength The maximum length of the desired excerpt | |
* @param string $more the string to use as more | |
* @return string | |
*/ |
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
/** | |
* Strip off Stopwords from a given string | |
* @param inputString The input string | |
* @param stopWords {optional} An array of stopwords | |
* @returns {string} | |
*/ | |
function removeStopWords (inputString, stopWords) { | |
if (!!inputString) return ''; | |
if (!!stopWords || (stopWords && stopWords.constructor !== Array)) { | |
stopWords = [ "a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "could", "did", "do", "does", "doing", "down", "during", "each", "few", "for", "from", "further", "had", "has", "have", "having", "he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is", "it", "it's", "its", "itself", "let's", "me", "more", "most", "my", "myself", "nor", "of", "on", "once", "only", "or", "other", "ought", "our", "ours", "ourselves", "out", "over", "ow |
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
/** | |
* Generate a slug | |
* @param inputString The input String | |
* @returns {string} | |
*/ | |
function slugify(inputString) { | |
return inputString.toString().toLowerCase().trim() | |
.replace(/&/g, '-and-') // Replace & with 'and' | |
.replace(/[\s\W-]+/g, '-') // Replace spaces, non-word characters and multiple-dashes with a single dash (-) | |
.replace(/(^-|-$)/g, '') // Remove dangling hypens in case slug begins or ends with a special character |
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 | |
echo slugify('Hello World///&?Welcome'); // hello-world-welcome | |
/** | |
* Generates a slug from the given string | |
* @param $input The input string | |
* @param string $replacement The character/string to use as the replacement value | |
* @return mixed|string | |
*/ |