Tagged: command line or console or terminal
How to create a Twitter archive of your tweets – Use WkhtmlToPDF and TweetsToRSS to save your tweets as PDF
“com.vsubhash.bash.twitter-to-pdf.txt” is a Unix/Linux shell script for archiving all messages posted by a Twitter account in PDF format.
The command to use is:
bash com.vsubhash.bash.twitter-to-pdf.txt \ realDonaldTrump \ 4000 \ nojs
The first argument to bash is the shell script. The second argument is the Twitter account. The third argument is the number of tweets to archive. The fourth argument is used if the Javascript used by TweetsToRSS causes problems with WKhtmlToPDF.
This code assumes that WKhtmlToPDF is available in /opt. Else, you need to update the script. WKhtmlToPDF uses konqueror browser under the hood. The good thing about it is that all HTML links are preserved.
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
if [ $# -lt 2 ]; then | |
echo -e "The format is:\n\t\e[35m`basename $0` \e[35;1mtwitter-handle-or-hashtag number-of-tweets [nojs]\e[0m" | |
exit | |
fi | |
# A backup of all files will be available in this Logs directory | |
if [ ! -d ~/Logs ]; then | |
mkdir ~/Logs | |
fi | |
cd ~/Logs | |
# Declare variables | |
iTweetsPerPage=100 | |
iPage=1 | |
iMaxPages=1 | |
iRemainder=0 | |
sDocs="" | |
# Initialize variables | |
let "iMaxPages = $2 / $iTweetsPerPage" | |
let "iRemainder = $2 % $iTweetsPerPage" | |
if [ $iRemainder -gt 0 ]; then | |
let "iMaxPages = iMaxPages + 1" | |
fi | |
# Javascript to remove YouTube IFrames. | |
sJavaScript="(function(){var arIframes=document.getElementsByTagName('iframe');var n = arIframes.length; for (var i=0;i<n;i++){ arIframes[0].parentElement.removeChild(arIframes[0]);}})()" | |
# If Javascript scripts cause problems, use the "nojs" argument to this | |
# shell script | |
if [ $# -eq 3 ]; then | |
sJavaScriptFlag="–disable-javascript" | |
else | |
sJavaScriptFlag="–enable-javascript" | |
fi | |
# Create archives | |
for (( iPage=1; iPage $1-meta.txt | |
echo "InfoValue: Subhash TweetsToRSS (www.vsubhash.com)" >> $1-meta.txt | |
echo "InfoKey: Title" >> $1-meta.txt | |
echo "InfoValue: The complete Twitter archive of $1" >> $1-meta.txt | |
echo "InfoKey: Subject" >> $1-meta.txt | |
echo "InfoValue: Collection of all tweets from $1" >> $1-meta.txt | |
echo "InfoKey: Author" >> $1-meta.txt | |
echo "InfoValue: $1" >> $1-meta.txt | |
echo "InfoKey: Keywords" >> $1-meta.txt | |
echo "InfoValue: $1, twitter, tweets, archive" >> $1-meta.txt | |
pdftk Complete-Twitter-Archive-of-$1.pdf \ | |
update_info $1-meta.txt \ | |
output The-Complete-Twitter-Archive-of-$1.pdf | |
if [ $# -eq 0 ]; then | |
notify-send "Twitter archive" "Completed for @$1" | |
else | |
notify-send "Twitter archive" "Error occurred for @$1" | |
fi | |
if [ -f The-Complete-Twitter-Archive-of-$1.pdf ]; then | |
cp ./The-Complete-Twitter-Archive-of-$1.pdf ~/Desktop/The-Complete-Twitter-Archive-of-$1.pdf | |
fi | |
# Cleanup | |
if [ ! -d $1-backup ]; then | |
mkdir $1-backup | |
fi | |
if [ -d $1-backup ]; then | |
mv -f $1-archive-*.pdf ./$1-backup | |
mv -f Complete-Twitter-Archive-of-$1.pdf ./$1-backup | |
mv -f $1-meta.txt ./$1-backup | |
mv ./The-Complete-Twitter-Archive-of-$1.pdf ./$1-backup | |
fi |
Windows 8/8.1 Tips and Tricks
New article has been published on http://www.vsubhash.com.
http://www.vsubhash.com/article.asp?id=127&info=Windows_8_Tips_Trick
I thought I would never have to write this article. A few years back, I had moved to Ubuntu and Gnome 2 desktop. I am quite happy with it. Even at work, I installed Ubuntu 10.10 with the last great Gnome 2 desktop. For my work duties as a technical writer, I have installed Windows VMs on VirtualBox. I never liked Windows 7 but Windows 8 made the earlier version look quite loveable. So far, I have installed Windows 8 five or six times and each time, I had to perform the same hacks all over again. Hence, I created this article where I can find it all in one place.
How To Remove Passwords From PDF Documents Using Linux Bash
And, prompt for password.
If you supply the password in the command line, it gets stored in bash history. So, we need to make the command prompt for password.
pdftk pathname_of_encrypted_pdf_doc.pdf output pathname_of_decrypted_pdf_doc.pdf do_ask
To install pdftk using the command (in Ubuntu/Mint):
sudo apt-get install pdftk
How To Download and Install “Google Web Fonts” In Linux
Many large-hearted font designers have made their fonts freely available on the Web. Google has collected the fonts and is hosting them at http://www.google.com/fonts. People mistakenly refer to them as Google Web Fonts. BTW, Google is showing its age. The search result still points to an old link and which arrives at /fonts after a lot of redirections.
You can refer to individual Google fonts in your web page with a header tag. One good thing about these fonts are that they work in IE browsers going as far back as IE 5.5 (Thank you, IE Tester).
On Linux, downloading and installing these fonts is very easy. Here is how I did it.
mkdir goog-web-fonts cd goog-web-fonts/ wget https://googlefontdirectory.googlecode.com/hg/ofl/ -r -nc -nd -np -A.ttf sudo mkdir /usr/share/fonts/ttf-goog sudo cp ./*.ttf /usr/share/fonts/ttf-goog/ fc-cache -r
UPDATE (23 June 2018): Google has moved the fonts to GitHub. Hence, the BASH code changes.
cd ~/Downloads mkdir ttf-goog-fonts wget https://github.com/google/fonts/archive/master.zip unzip fonts-master.zip find fonts-master -type f -name "*.ttf" > fonts.list cat fonts.list | while read sReadLine do do mv $sReadLine ttf-goog-fonts done sudo cp -R ttf-goog-fonts /usr/share/fonts fc-cache -r