Multi-Search3
Showing posts with label javascript tips. Show all posts
Showing posts with label javascript tips. Show all posts

MonkeyWordSearch - Powerful, Free Linux Keyword-search Utility!




Searching for a free search program(Linux bash script) with GUI input controls? Want to see results on your browser? Love keyword highlighting? Need to see not just result fragments from file but the file itself? Want to restrict searches to ASCII/text files only but need to view list of files that weren't searched also? Want a clickable link for EVERY FILE with or without a match within the domain of the search? Want to see the progress of the search with an oscillating progress bar and a scrolling percentage-completed tailbox?

Welcome to MonkeyWordSearch! The Monkey's got it all for you!

Read on.

REQUIREMENTS

1.Zorin7 OS [Ubuntu] Linux
2.A modern browser that supports CSS3 transitions [I used Chrome28.0, Firefox28.0, Opera12.16]
3.Zenity [I used version 3.6.0]
4.GNU Awk 4.0.1
5.Rxvt v2.6.4
Screen resolution: 1280 x 800 [Recommended]

FEATURES

MonkeyWordSearch is a powerful recursive keyword search utility with GUI input box, file select control, file-type and maxdepth filters which let you search files on your Linux PC/Laptop for your search phrases. It's features are listed below.

1.View results on browser: Display the search results on the browser.

2.Highlight keywords/search phrase[Case-insensitive!]: Highlight the keywords within search results for emphasis. You'll like it that Monkey displays a match regardless of whether it is UPPERCASE, lowercase or CamelCase!

3.List text files with/without result: Locate and separately list which files contain results and which do not.

4.List non-text(skipped) files: Locate and separately list skipped non-text/ASCII files.
4a.Here's something even more interesting. Click on the [Clickable File List] button to view the clickable version of the same page useful for viewing pdfs, images etc but remember to NOT CLICK on executable or very large files.

5.Display results as Encoded or Normal: Click anywhere inside the result box or click on the [View Results] link above the result box to display the results page that pops up for text-view or web-view of the search results. While the top [HTML-Encoded text view] is always intact, remember that the bottom [Normal HTML web view] below it may sometimes seem broken since incomplete HTML code in search results might make it look broken. This is normal behavior. Click on the [Result Fragments: Normal] button on top of the page TWICE to bring up the normal section to top.

6.View search file itself, not just results: Click on the [View File] link on the top-right of the search result box to view the file on the browser. If this link did nothing, then the filename may have goofy characters in it and, most often we can click either on the search result box or the [View Results] link and then click on the link to the file on top of the results page. If this didn't work either, at least we have the filename parts with the path so we can open the file manually.

7.Exclude big files from search but view their names: Exclude big files [greater than 5MB] from the search but view their names.

8.Find search progress percentage-completed [MonkeyWordSearchTailbox window]

How do I activate/de-activate this window? This window is activated by default. To de-activate it, find and comment these two lines in the [$HOME/tools/MonkeyWordSearch/Mws.bash] file.

[You may activate it again by uncommenting the two lines above if you choose to.]

How is it useful? Once you press [OK] on the 4th and final input box, you see this window if it is activated. This Rxvt terminal window with a fast-scrolling tailbox displays the total file count, percentage-completed, current file being processed with path among other things.

How do I exit from it? Press [CTRL-C] from within this window to exit from it. Double-click on [$HOME/tools/MonkeyWordSearch/MwsCleanup.bash] script to terminate MonkeyWordSearch completely. Find more details at the [III.Termininating MonkeyWordSearch] section below.

Is there a search log? Remember to check the [$HOME/tools/MonkeyWordSearch/MwsSearchLog.htm] file for the complete record of the search after the search completes.

9.MonkeyWordSearch window: Once you press [OK] on the 4th final input box, this [oscillating progress-bar] window starts up along with the [MonkeyWordSearchTailbox] window. Along with keyword and other input parameter details, you can also view the search progress with an oscillating progress bar. You may stop and exit from the Monkey before it completes by pressing [Escape] from within this window and pressing [Ctrl-C] from the MonkeyWordSearchTailbox window. Don't forget to cleanup strays with [$HOME/tools/MonkeyWordSearch/MwsCleanup.bash] before re-running the Monkey!

10.Use 4 GUI input boxes: These are used for inputs. Press [Escape] to exit.


NOTE 1: LINUX COMMANDS AND TOOLS USED
You wouldn't believe it that a simple program such as MonkeyWordSearch needs so many Linux commands and tools to fetch you the results! First you need to manually verify or set 4 files at the top of the $HOME/tools/MonkeyWordSearch/Mws.bash script. Change samples below to suit your environment.

#Define your browser location below
BROWSER=/usr/bin/chrome
#Define awk location below
AWK=/usr/bin/awk
#Define rxvt location below
RXVT=/usr/bin/rxvt
#Define zenity location below
ZENITY=/usr/bin/zenity

Apart from these, there are 17 Linux commands/tools Monkey needs. You may appreciate the fact that Monkey automatically scans and sets the locations of these following essential Linux commands without you having to manually check each one of them. When you run Monkey, one of the first things it does is to check for these 17 files and error out if it misses anything. If MonkeyWordSearch doesn't start up, open the [$HOME/tools/MonkeyWordSearch/MwsMissing.out] file to view the details of found and not found files and fix the problems if any and re-run Monkey after fixing problems. Here's the list of these mostly standard and almost always available 17 Linux commands/tools:

mkdir bash mv rm touch echo grep cat sed find sleep file wc expr bc cp sort 

NOTE 2: SIZE OF EXCLUDE FILES
While leaving out non-text/ASCII files, Monkey also excludes text files bigger than 5MB from being searched but lists their names so you can search those big files manually if you choose to. You can change the default big file size by searching for and changing the line below in the Mws.bash script

if [ $fsize -le 5242880 ]; then

NOTE 3: OPENING FILES FROM MONKEYWORDSEARCH BROWSER LINKS OR BUTTONS
MonkeyWordSearch has made it easy for you to be safe when you click on files to open them from the browser by segregating non-text/ASCII files and excluding them from being searched. Again, even among text/ASCII files it picks out and excludes files bigger than 5MB from being searched. Best of all, MonkeyWordSearch presents you a  skipped(non-text) files page with non-clickable list of file names by default, but you can make it clickable by pressing the button just above the list. Talk about having the best of both worlds, safety and convenience! As a general rule of thumb, though, ALWAYS exercise caution when clicking on links because of the way browsers make file-associations. For example, don't click on executables, huge files etc.

NOTE 4: BROWSE YOUR SEARCH FOLDER WITH YOUR BROWSER!
Click on the link to the right of [Search Location] on the top of the main search result page to browse the search folder with your browser.

NOTE 5: X-RAY-MONKEY: MONKEY FOUND A RESULT BUT I CAN'T FIND IT IN THE FILE - HEY WHAT'S UP?
The result box shows a match but when you open the file and search for it you don't find it, what's going on? This may happen when you're searching html files where there could be matches found in non-content areas such as html code or javascript code. If you're opening the html search file with your browser, rightclick and select [view page source] and then press [CTRL-F] to do a search and you'll find it.

NOTE 6: [ViewFile] LINK ON TOP-RIGHT OF SEARCH RESULT BOX WON'T WORK - HEY WHAT'S UP?
If the [ViewFile] link on the top-right of the search result box doesn't open the file, the filename possibly has some weird characters. Click inside the result box to open the results page on a new tab/window and click on the link on the top of the page to open the file. If this doesn't work either, at least we have the path and filename of this rogue! Just open it with your file manager.

NOTE 7: RESULTS FROM A ZIP FILE IS SHOWING UP IN THE RESULT BOX - HEY WHAT'S UP?
Sometimes you may see results from zip files shown in the result box. This may be normal. If a html file is compressed into a zip file, it may be seen as "HTML document, UTF-8 Unicode text, with very long lines" by the [file] command that is used to filter text/ascii files. In this case, the file may be opened by a text editor.

NOTE 8: SMART IDEA - SAVE THAT SEARCH!
Let's say you just searched for files with the keyword [Linux] and want to save it for future. Just copy the [Mws.htm] file and rename it to something such as [Mws.linux.htm]. This will benefit especially those who keep their stuff well-organized on their PC/Laptop since they will have only one two places to search for anything! Isn't this a good idea?

NOTE 9: DUMB SEARCHES[?]
1.Avoid searching system folders if you don't intend to.[Eg. /var, /usr, /etc etc.]
2.If you delete lots of files using PcManFM GUI file manager, then your [/root/.local/share/Trash] folder for root user or [$HOME/.local/share/Trash] folder for non-root users may be huge. Remember to avoid searching these if you don't intend to.
3.Your [$HOME/.thumbnails] folder may have tens of thousands of files, you may not want to search these.

CONCLUSION

This Monkey sure made me go all bananas! Seriously, it took a lot of time and effort to get it going but it sure will make your life easy if you choose to use it! MonkeyWordSearch makes searching files on your Linux system for keywords a much better experience first since it lets you view results on your browser with keyword highlighting. Secondly you can view not just the results but the file itself. Thirdly you get a clickable list of files with results and those without. Fourthly you get a clickable list of skipped(non-text) files. And most of all, it lets you view the progress of the search the whole time while letting you terminate it INSTANTLY with just a double-click on [$HOME/toos/MonkeyWordSearch/MwsCleanup.bash] then clicking [Open] or by typing [mwsclean] from the commandline!

Here's the secret. Once you get used to typing [mws] and [mwsclean] from the commandline or its equivalent of double-clicking on [$HOME/toos/MonkeyWordSearch/Mws.bash] and [$HOME/toos/MonkeyWordSearch/MwsCleanup.bash] and then clicking [Open] to start and terminate the Monkey, I guarantee you'll be using them all the time without knowing it!

  • Visit my website [Sqlhtm.com]
  • Read my blog at Blogger [Sqlhtm.blogspot.com]
  • Read Some Top Tweets From Me And Others!
  • Read Some DIY[Do-It-Yourself] Ideas Of Mine
  • PolarVerses - Display Your Tweets/Bible Verses Proudly! Free!
  • Multi-search3 - Powerful 3-in-1 Web Search! Free!
  • Aesop Fables Browser - Legendary Animal Tales With My Short Summary Tweets! Free!
  • Font3dTemplates - Slideshow Of Wordart I Made With It.[Chrome15.0-Win7/XP]. Free!
  • Bible Reader - You can still read the Bible from here! Free!
  • A Cool Database Tool I Made! Free!
  • Another Neat Database Tool You Can't Be Without! Free!
  • Of Bible Quiz, Number Crunching, Javascript Tips and Indian Budget.

    Bible Quiz

    It will be close to 3 months tomorrow since I wrote the last blog post[Sig3-Simple Image Gallery For Linux]. While it has always been my top priority to keep this blog and my sqlhtm.com website updated as frequently as possible, it has been a hard thing to do because of where I am in life now - away from home, waiting anxiously to get back to work, family and life. Luckily, what has been a loss of productivity on the blog end, has been a gain for the website since I have added a few more stuff to the website.[Bible Quiz, Aesop Tweets Browser and Aesop Tweets Slide show]. In this post, I just wanted to write about a bunch of interesting things that came my way during the last few weeks.

    1. BIBLE QUIZ


    Do you know there is an interesting little Bible Quiz at sqlhtm.com? This is the latest Html/Javascript online applications there. It is a tiny little starter quiz with just 20 questions from the first few chapters of the first two books of the Bible[Genesis and Exodus]. While you can easily score 100% with single answer questions, you may not do so with a multiple-choice type quiz, at least not easily! Don't complain, things have been smoothed out here. For one thing, you can click on any answer choice of any question any number of times without time or number of attempt restrictions. For another, you just need to press the "Check Answer" button for a hidden answer box with the answer text to slide out for you! I am sure you will find this quiz exciting and informative. Go ahead, take a look and make sure you are a real Bible expert!

    2. NUMBER CRUNCHING


    You know what, I also tripped on the words "1 crore crores" somewhere somehow and didn't know how much it really stood for. So I started to dig a little, crunch some 1's and 0' and ended up with the table I think you will find useful, specially if you are an Indian NRI, since it has a side-by-side comparison of the numbers of the Indian and Western number formats. This table has been heavily inspired by a website I found on my mobile phone, which I could not find again to make a mention of! While I want to thank them I also want to remind you that the numbers are valid for their own currencies and not as conversion of, for example, the US dollar to the Indian rupee or the Indian rupee to the US dollar. In other words, we're doing number analysis here, not currency conversion.


    No of ZeroesAmt in Numbers[India]Amount in Words[Indian]Amt in Numbers[West]Amt in Words[West]
    5 Zeroes1,00,0001 Lakh100,000100,000
    6 Zeroes10,00,00010 Lakhs1,000,0001 Millions
    7 Zeroes1,00,00,0001 Crore=100 Lakhs10,000,00010 Millions
    8 Zeroes10,00,00,00010 Crores=1000 Lakhs100,000,000100 Millions
    9 Zeroes1,00,00,00,000100 Crores=10,000 Lakhs1,000,000,0001 Billions=1,000 Millions
    10 Zeroes10,00,00,00,0001,000 Crores=1,00,000 Lakhs=1 Lakh Lakhs10,000,000,00010 Billions=10,000 Millions
    11 Zeroes1,00,00,00,00,00010,000 Crores=10,00,000 Lakhs=10 Lakh Lakhs100,000,000,000100 Billions=100,000 Millions
    12 Zeroes10,00,00,00,00,0001 Lakh Crores=1,00,000 Crores=1,00,00,000 Lakhs=100 Lakh Lakhs1,000,000,000,0001 Trillion=1000 Billions=1 Million Millions=1,000,000 Millions
    13 Zeroes1,00,00,00,00,00,00010 Lakh Crores=10,00,000 Crores=10,00,00,000 Lakhs=1000 Lakh Lakhs10,000,000,000,00010 Trillion=10,000 Billions=10 Million Millions=10,000,000 Millions
    14 Zeroes10,00,00,00,00,00,0001 Crore Crores=100,00,000 Crores=100 Lakh Crores=100,00,00,000 Lakhs=10,000 Lakh Lakhs100,000,000,000,000100 Trillion=100,000 Billions=100 Million Millions=100,000,000 Millions

    All the numbers crunched and tabled, I finally found the answer to my nagging question: How much really is "1 crore crores"?

    Answer:
    1 crore crores is 100000000000000[14 zeroes after 1], [10,00,00,00,00,00,000 in Indian number format][100,000,000,000,000 in Western number format].
    1 crore crores happens to be Western 100 Trillion[=100,000 Billions][=100 Million Millons][=100,000,000 Millions].
    1 crore crores happens to be Indian 100 Lakh Crores[=10,000 Lakh Lakhs].

    My problem solved, I still have a bigger question: Why should some people in the world have soooooo much more money than all the others???

    I think, in all fairness, income distribution should be more equitable where ever you are, most everyone hovering around the median, give or take, for example, a 10-time disparity between the highest and the lowest.

    To illustrate this, consider a hypothetical situation where the lowest income someone makes is $10/hr [$1600/month][$20,000/yr] and the highest income that anyone can make is capped at $100/hr [$16,000/month][$200,000/yr]. While you may say this kind of thing is hard to implement in the current scheme of things, how can you justify a handful of individuals making  more money than even some small countries? How can you turn a blind eye to how this in turn deprives thousands of unemployed people's opportunity to get employed and support their loved ones? THERE'S GOT TO BE A WAY TO SPREAD THE WEALTH OF THE NATIONS MORE EVENLY AMONG THE PEOPLE. What would be the downside to this kind of approach? What do you think?

    3. JAVASCRIPT TIPS


    Talking of numbers, I also wanted to share 2 functions I used in my Bible quiz, that use numbers in interesting ways.

    Tip 1 [Deep and complex nested If statement]

    I have used the Javascript "IF" statement(short form) before but wasn't sure how nested or complex it could be. The Bible quiz gave me a chance to test out and use a complex nested short form of the "IF" statement.

    Problem

    Every one of the 20 questions in the Bible quiz has multiple-choice answers [a,b,c,d,e,f and g]. I need to convert these into numbers [1,2,3,4,5,6 and 7] so I can use it to retrieve the correct answer from the answers array.

    Solution

    Look at the code below. Receiving one of the letters "a" through "g" as input, this function assigns a corresponding number "1" through "7" as the value of the variable "anscnv" and returns it.

    function ansConv(let) {
    var anscnv = "";
    anscnv = ((let == 'a') ? 1 : ((let == 'b') ? 2 : ((let == 'c') ? 3 : ((let == 'd') ? 4 : ((let == 'e') ? 5 : ((let == 'f') ? 6 : 7))))))
    return anscnv;
    }        
    
    In psuedo code, this nested if means,
    If "let" is equal to "a" then return 1;
    Else if "let" is equal to "b" then return 2;
    Else if "let" is equal to "c" then return 3;
    Else if "let" is equal to "d" then return 4;
    Else if "let" is equal to "e" then return 5;
    Else if "let" is equal to "f" then return 6;
    Else return 7;

    Tip 2 [Ceil is the champ here!]

    Problem

    I have a little show/hide accordion blue answer box on the top of every row [5 questions per row] that opens up when you press the "Check Answer" button and closes when you click on the "Close" button on the top right. That means a total of 4 boxes for 20 questions. The problem is to store
    "1" as the box number in the variable ansboxnum when we click any of the five "Check Answer" buttons on the 1st row, 
    "2" as the box number in the variable ansboxnum when we click any of the five "Check Answer" buttons on the 2nd row, 
    "3" as the box number in the variable ansboxnum when we click any of the five "Check Answer" buttons on the 3rd row and
    "4" as the box number in the variable ansboxnum when we click any of the five "Check Answer" buttons on the 4th row.

    Solution

    There could be many ways to solve this but here is one. Look at the line of code below.

    
    var ansboxnum = (Math.ceil(q / 5) <= 1 ? 1 : Math.ceil(q / 5)); 
    

    Assuming q to be the question number[1 through 20], this is what the code above does. If q divided by 5 rounded up(ceil) is less than or equal to 1 then it stores 1 as the value of the variable "ansboxnum", else it stores q/5 rounded up(ceil) as ansboxnum. This means,
    for q in questions [1,2,3,4,5] it stores 1,
    for q in questions [6,7,8,9,10] it stores 2,
    for q in questions [11,12,13,14,15] it stores 3 and
    for q in questions [16,17,18,19,20] it stores 4, exactly what we need.

        1/5=.2; ceil(.2)<=1 so return 1[questions-1st row/answer box #1]
        2/5=.4; ceil(.4)<=1 so return 1[questions-1st row/answer box #1]
        3/5=.6; ceil(.6)<=1 so return 1[questions-1st row/answer box #1]
        4/5=.8; ceil(.8)<=1 so return 1[questions-1st row/answer box #1]
        5/5=1.0; ceil(1.0)<=1 so return 1[questions-1st row/answer box #1]
    
        6/5=1.2; ceil(1.2)=2 so return 2[questions-2nd row/answer box #2]
        7/5=1.4; ceil(1.4)=2 so return 2[questions-2nd row/answer box #2]
        8/5=1.6; ceil(1.6)=2 so return 2[questions-2nd row/answer box #2]
        9/5=1.8; ceil(1.8)=2 so return 2[questions-2nd row/answer box #2]
        10/5=2.0; ceil(2.0)=2 so return 2[questions-2nd row/answer box #2]
    
        11/5=2.2; ceil(2.2)=3 so return 3[questions-3rd row/answer box #3]
        12/5=2.4; ceil(2.4)=3 so return 3[questions-3rd row/answer box #3]
        13/5=2.6; ceil(2.6)=3 so return 3[questions-3rd row/answer box #3]
        14/5=2.8; ceil(2.8)=3 so return 3[questions-3rd row/answer box #3]
        15/5=3.0; ceil(3.0)=3 so return 3[questions-3rd row/answer box #3]
    
        16/5=3.2; ceil(3.2)=4 so return 4[questions-4th row/answer box #4]
        17/5=3.4; ceil(3.4)=4 so return 4[questions-4th row/answer box #4]
        18/5=3.6; ceil(3.6)=4 so return 4[questions-4th row/answer box #4]
        19/5=3.8; ceil(3.8)=4 so return 4[questions-4th row/answer box #4]
        20/5=4.0; ceil(4.0)=4 so return 4[questions-4th row/answer box #4]
    
    
    Remember this can extend the same way to any number of boxes.
    Nice little way to solve a tiny little problem!

    4. INDIAN BUDGET[2014-15]


    I recently read about the Indian budget in the papers and looked for something that would interest me as an NRI. Sure, yes, I did find some thing interesting! The tax-free baggage allowance for inbound fliers has been upped to Rs.45,000[$748 USD] from Rs.35,000[$582 USD] for the budget year 2014-15. So, travellers, remember to bring that $700 USD in, invest, donate or make good use of it anyway you can!




    BlogCollage


    Blog Collage - Top Random Posts In No Particular Order

    Mouseover the images for title and comments