Friday, December 2, 2016

How Do I Make a JSON Pretty Printer App Using PHP for Development/Debugging Use as a Coder?

Ya'll know you don't wanna be posting your app's JSON responses, which may include sensitive information, to some third party website which could easily or accidentally log this info... think, decrypted passwords might be in your response, API keys, the name of your app. Lot's of stuff ain't nobody but you should see. So here, make your own JSON PRETTY PRINTER using PHP and RUN IT LOCALLY on your comp. Yea boi! Get it!
<?php
$str = <<<'EOT'
{"name_first":"John"}
EOT;
echo json_encode(json_decode($str), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
^ Save the file. Name it something such as json-pretty-printer.php and then run it on the command line by typing 'php' then the path to your script. Hit enter. Boom.

Wednesday, January 27, 2016

How can I search the entire (unix) file system for files whose name contains a specific substring?

# To list files whose name contains "yoursearchterm"
find / -name "*yoursearchterm*" -print
Swap the "/" with a more specific path to limit your search. Add "-maxdepth 1" after the path and before "-name" to limit your search to a single directory.

Credit: http://stackoverflow.com/a/11329078

About Me

My photo
I code. I figured I should start a blog that keeps track of the many questions and answers that are asked and answered along the way. The name of my blog is "One Q, One A". The name describes the format. When searching for an answer to a problem, I typically have to visit more than one site to get enough information to solve the issue at hand. I always end up on stackoverflow.com, quora.com, random blogs, etc before the answer is obtained. In my blog, each post will consist of one question and one answer. All the noise encountered along the way will be omitted.