LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LQ Suggestions & Feedback (https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/)
-   -   A facility for storing useful scripts for general use? (https://www.linuxquestions.org/questions/lq-suggestions-and-feedback-7/a-facility-for-storing-useful-scripts-for-general-use-4175724212/)

hazel 04-19-2023 12:23 AM

A facility for storing useful scripts for general use?
 
Today I found two useful scripts on the first page of "Latest posts". One invoked Google Translate to translate strings from the command line (the actual script was in a linked blog), and the other was a wrapper for a fingerprint reader to turn it into a screen-unlocker. Sadly, these will gradually disappear from sight as more threads are added.

It would be nice to have a little repository where such gems can be stored.

dugan 04-19-2023 11:13 AM

I'd make a page on the horribly-underused LQ Wiki and link to them there.

teckk 04-24-2023 05:14 PM

@hazel
Most basic little translator in bash. Needs curl. You could also use wget.

trans.sh
Code:

#!/usr/bin/bash

agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:110.0) Gecko/20100101 Firefox/110.0"

echo -e "\nGoogle Translator\n"
echo -e "For language abbreviations look at: "
echo -e "https://developers.google.com/admin-sdk/directory/v1/languages\n"

read -p "Enter input language: " inLang
read -p "Enter output language: " outLang

read -p "Enter phrase to translate from "$inLang" to "$outLang" :" phrase

phrase=${phrase// /+}

url="http://translate.googleapis.com/translate_a/single?client=gtx&sl=${inLang}&tl=${outLang}&dt=t&q=${phrase}"

echo -e "\nThis is the google api url: "$url"\n"

curl -A "$agent" "$url"

Example usage:
Code:

bash ./trans.sh

Google Translator

For language abbreviations look at:
https://developers.google.com/admin-sdk/directory/v1/languages

Enter input language: de
Enter output language: en
Enter phrase to translate from de to en :Ich habe Probleme mit dem Programm awk, um den zweiten Treffer eines Strings auszugeben

This is the google api url: http://translate.googleapis.com/translate_a/single?client=gtx&sl=de&tl=en&dt=t&q=Ich+habe+Probleme+mit+dem+Programm+awk,+um+den+zweiten+Treffer+eines+Strings+auszugeben

[[["I'm having trouble using the awk program to print the second match of a string","Ich habe Probleme mit dem Programm awk, um den zweiten Treffer eines Strings auszugeben",null,null,3,null,null,[[]],[[["1fdac2347d4ad2bfc63cca9b4fbecbbb","de_en_2022q1.md"]]


rtmistler 04-24-2023 06:14 PM

Quote:

Originally Posted by hazel (Post 6425594)
It would be nice to have a little repository where such gems can be stored.

Also known as a git repository.


All times are GMT -5. The time now is 04:25 PM.