Show HN: Anycomplete
github.com
github.com
[0]: http://stackoverflow.com/questions/6428502/google-search-aut... [1]: https://webmasters.googleblog.com/2015/07/update-on-autocomp...
#!/bin/bash
S="$(echo "$@" | sed -E 's, +,+,g')"
g(){
curl -sS "https://suggestqueries.google.com/complete/search?client=firefox&q=$1" \
| sed -E 's,.*\[([^]]*)\].*,\1,;s,",,g' | tr , '\n'
}
d(){
curl -sS "https://duckduckgo.com/ac/?q=$1" \
| sed -E 's,"phrase":|[][{}"],,g' | tr , '\n'
}
paste -d , <(g $S) <(d $S) | column -t -s , curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
| json_pp | sed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'There's a blog dedicated to shaming sites that do this: https://curlpipesh.tumblr.com/#_=_
/s
``` echo "test... test... test..." | perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see' ```
But generally speaking, you're right. You're taking a risk every time you run executable code from the internet, and if you don't want to live in a paranoid state of fear constantly, you have to balance security and convenience. If you check that it says "https" in the beginning and that you trust the source, then you're probably fine.
To run this with macOS, I had to use the GNU version of sed. I installed it with
$ brew install gnu-sed
And it is then called with 'gsed' instead of 'sed'.As an avid Perl programmer, I had json_pp in my $PATH - for everyone else - it is here: https://metacpan.org/pod/JSON::PP
You can install it with cpanm:
$ cpanm JSON::PP
If you don't have cpanm, you can install it with $ curl -L https://cpanmin.us | perl - App::cpanminus
The modified command line from above then becomes: $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' \
| json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
Here is a little Bash function to encapsulate this: $ function c() { curl -sS "https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=$1" | json_pp | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'; }
Which then allows you to use it like this: $ c hacker
hacker news
hacker typer
hackerrank
hackerman
hackers movie
hacker fare
hackerone
hackers cast
hacker pschorr
For spaces in your query, use a '+': $ c New+York
new york times
new york and company
new york giants
new york post
new york daily news
new york weather sed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p;}'
(Edited to remove previous advice about inserting a newline) function c() {
url='https://www.google.com/complete/search?client=hp&hl=en&xhr=t'
# NB: user-agent must be specified to get back UTF-8 data!
curl -H 'user-agent: Mozilla/5.0' -sSG --data-urlencode "q=$*" "$url" |
jq -r .[1][][0] |
sed 's,</\?b>,,g'
}
Example: $ c ':)' ':('
) ( meaning
) ( emoticon
) ( ͡° ͜ʖ ͡°)
) ( emoticon meaning $ curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' | jq . | gsed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p}'
(see my other comment about gsed vs sed) curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' | jq . | sed -nE '/<\/?b>/{s```g;s`"|,|^ *``g;p;}'
(Edited to remove previous advice about inserting a newline) curl -sS 'https://www.google.com/complete/search?client=hp&hl=en&xhr=t&q=aurora' | jq -r '.[1] | .[][0] | sub("</?b>"; ""; "gi")'Ideally it showed a drop down under where you're typing much like most IDEs would, but support was shotty at best. I really wish there were more OS level hooks for this sort of thing, or a more standardized way to understand what the user is typing and where, but that's not something I ever expect to happen. My app was basically a keylogger while the one in the post is more like a separate entity altogether.
IIRC Autohotkey makes an application from your hotkey choice that you then run (eg via autostart or using an icon) to instate the hotkey afresh every reboot.
To this end it seemed inferior to the KDE equivalent for me, but that could just be familiarity bias.
Not just that, no. Its programming language is godawful, but the tight integration with the Windows API makes it powerful in a way that shell scripts and the like cannot easily match.
- We have a team call and a team agenda doc, I'm using a hotkey to open a chooser, which has an option "goto team call" that fires up the call window and the doc.
- We deal with prod/dev so I made another item in the chooser "log in to dev server" which opens a chrome incognito window, presses the one password unlock shortcut and then I'm just waiting there to input 2 factor.
As I uncover more of these, I'll be coding them up and using the master chooser to deal with any annoying workflows. :)
Universal autocomplete via google api? Hmm, something to think about.
1) Keyloggers
2) Filter bubbles
3) Offline tax
Memorizing and reusing a single password is the worst thing you can do. The number of leaks and brute-force attacks are increasing, and you should really be generating random and unique passwords per website if you aren't.
To get an idea of how easy it is to crack a leaked password, download a public list of a website you know[1] (ex. L1nk3d1n), you'll probably find the password you used at the time of their leak in the list, since ~97% of them have already been cracked.
Related, reminds me of the havoc you could wreck on phpBB boards with [you] command enabled. For those who haven't seen it, a [you] BBcode is replaced on display with viewing user's name.
So you'd generally write a reasonably sounding comment, with a sentence like "This is something [you] was supposed to do.", you'd post it and then it was time to eat popcorn.
[edit] Actually, I guess the way you described it, it could go the other way. You start writing some argument, and google shows you some stats that show you're wrong, or something. That would be neat.
[0]: https://github.com/nathancahill/anycomplete/blob/master/anyc...
Search for "swing", then in the search box, delete that and type in "play". It'll auto-complete with something like "playground swing".
Now in a new tab, search for "music". Then delete that and search for "play". You'll get different results.
(doesn't work with the browser search box, has to be the one in the page itself)
FTFY