Wednesday, December 10, 2014

Converting PDF to a series of images... and back...

Books:

1. gather all images into one directory
2. edit / crop using GIMP
3. in GIMP, export as *.mng file

4. convert to pdf:
convert -interlace none -density 300 -quality 100 infile.mng outfile.pdf

---


...or PNGs...

convert -quality 100 input.pdf output-%04d.png

for really high quality (ie for TV slides):
convert -interlace none -density 300 -quality 80 -resize 1200 infile.pdf outfile_%03d.jpg

to convert images to pdf:

convert *.png output.pdf

-- pdf may be too large; use smallpdf.com to compress:

http://smallpdf.com/compress-pdf

Three other linux-based options to compress PDFs:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=outfile.pdf infile.pdf

- slightly higher quality, slightly larger size
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=outfile.pdf infile.pdf

- much more precise, much slower, not much smaller...
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/screen -dEmbedAllFonts=true -dSubsetFonts=true -dColorImageDownsampleType=/Bicubic -dColorImageResolution=72 -dGrayImageDownsampleType=/Bicubic -dGrayImageResolution=72 -dMonoImageDownsampleType=/Bicubic -dMonoImageResolution=72 -sOutputFile=outfile.pdf infile.pdf


Wednesday, November 19, 2014

Rotating Backgrounds in Fedora/Linux

If your Linux flavor uses Gnome, there are wallpapers available that change throughout the day.


Great.

But, what if you want your own?

There are applications that allow you do to this, but here's a script to do it simply.

First, put the pictures you want to use in a ~/Pictures/Backgrounds directory:


Create this script somewhere handy:


Then run it:
chmod +x ./build_background_xml3.sh
./build_background_xml3.sh

Done!

Wednesday, August 27, 2014

Automating Passwordless Access

Assuming you have generated rsa keys (ssh-keygen) and assuming that ssh-copy-id is NOT working for you...

Here's the command:
cat ~/.ssh/id_rsa.pub | ssh -p 22 <login>@<dest> "cat >> .ssh/authorized_keys";
Where <login> is your username and <dest> is the server to which you're sending the public key.

OR, if you do this often, create passwordless.sh:

To run it:
chmod +x passwordless.sh
./passwordless.sh <login> <dest>

Saturday, August 23, 2014

Android: 'Insufficient Storage Available'

I HATE this message. But this article has helped me to resolve it.

I'm tired of removing apps so I can install another one, when I know there's ample space for them.

Finally, I've had enough; thanks, Google, IT World, and Kevin Purdy:

There is a kind of clean-sweep method of wiping out the cache on all your apps at once. You'll have to clear enough space for it, of course, but if you can fit the 1.31 MB App Cache Cleaner on your Android, you'll free up much more space in return. It's an ad-supported product, with occasional pop-ups. But ignore whatever goofy game it wants you to install, look at the "Total" count in the upper-right corner, and then click the big green "Clean" button at the bottom. That's a bit more space, so try installing that app that wouldn't fly once more.

I'm in love with my Android again.

Tuesday, April 29, 2014

Google Hangouts Video Call - Allow both talk plugins...

Ok, I just spent 30 minutes tinkering with Google Hangouts (Fedora, Chrome) to try to get video calling working.  Every time I tried to initiate a video call, a new window would pop up with a message that read:

Select "Allow" for both Google Talk plugins in order to access the video call.

Of course, there isn't anything to click to enable the plugins.  Weird.

Eventually, I found out that by telling Chrome to automatically run all plugins, it would work.

chrome://settings/content

Scroll down to "Plug-ins" and select "Run automatically (recommended)"

Once that's done, start a video call; works fine.

Since I'm paranoid, I went back and changed the Plug-ins setting back to "Click to play" and, guess what?  Video calling still works!

(Lustre) Best practice for changing file permissions

On a Lustre filesystem, don't use chmod/chgrp/chown by themselves.

The best method incorporates the lfs find command:
lfs find <subdirectory> | xargs chgrp <new group>
chmod or chown commands with -R option (or using the normal find) are not very fast if the subdirectory contains lots of files.

Friday, October 25, 2013

Capturing RTMP video (aka Flowplayer) (in Fedora)

It may not be very elegant, but it works.

First, install rtmpdump:
sudo yum install -y rtmpdump

Then, create this script somewhere handy:
#!/bin/bash
sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT
echo starting
rtmpsrv | tee rtmp.txt
echo ended
sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -j REDIRECT

Run the script, then, while it is running, try to watch the video in your browser.  If it is an RTMP stream, the terminal should show some capture information.  Ctrl+C in the terminal.

Now, you may have to edit the rtmp.txt output file to remove extra text, but leave the "rtmpdump" commandlines.

Finally, execute:
sh ./rtmp.txt

...to download the video.

(Create an alias:  alias capture='~/path/to/rtmpdump/script.sh')

Monday, June 10, 2013

Google Docs - Inserting Date in the Footer

Now that Google Drive Documents support scripts, it is possible to, say, create a footer that contains the date that the document was last accessed.

In your Google Doc, click Tools | Script Editor.

Copy/paste the code below, and save the script.


/**
 * The onOpen function runs automatically when the Google Docs document is
 * opened. It will add a "Tools" menu with an "Update Footer" option. It also
 * (automatically) updates the date in the footer as soon as the documents is
 * opened. (WARNING: Any footer content will be removed/deleted.)
 */
function onOpen() {
  // Add a menu with some items, some separators, and a sub-menu.
  DocumentApp.getUi().createMenu('Scripts')
      .addItem('Update Footer', 'onEdit')
      .addToUi();
  onEdit();
};
function onEdit() {
  var doc = DocumentApp.getActiveDocument();
  var footer = (doc.getFooter()) ? doc.getFooter() : doc.addFooter(); // Thanks, Martin!
  footer.setText("");
  var divider = footer.appendHorizontalRule();
  var footerText = footer.appendParagraph('Confidential and Proprietary - Accessed ' + new Date());
  footerText.setFontSize(9);
  footerText.setForegroundColor('#4a86e8');
  footerText.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
  return doc;
};


Return to your document, and reload it; the footer will automatically be created.  (NOW it will! Thanks, Martin!)  If you want to update the footer, you can click the Script | Update Footer menu item.

That I know of, there isn't yet an "onSave" or "onEdit" trigger in Google Documents - but, if that comes about, this will be an even more awesome tool! (*hint,hint, Google!)  You CAN, however, use a "clock tick event" but I haven't gone there yet.

Thursday, April 11, 2013

Nuvola Player on Fedora

Nuvola Player is a nifty interface for Google Music.

Due to dependencies and such, I found this page helpful: https://launchpad.net/nuvola-player/+download

I downloaded NuvolaPlayer version 1.1.2, though it is not the latest...


Extract:
tar -xvf nuvolaplayer-1.1.2.tar.gz 
cd nuvolaplayer-1.1.2/

Run the configuration:
./waf configure

In my case, there were some dependencies that I don't need/can't use, so:
/waf configure --no-lastfm --no-unity-quick-list --no-svg-optimization

Build and Install:
./waf build
sudo ./waf install

I also had to install the Gnome extension:
sudo yum install gnome-shell-extension-mediaplayers

Run NuvolaPlayer (either via terminal or Applications in Gnome).

Aaaaand, awesomeness.


Wednesday, February 20, 2013

Editing / Creating Bookmarklets



Bookmarklets are really cool.

I've updated the Bookmarklet Editor; drag this link to your bookmark toolbar:


So, what does it do?

Well, editing bookmarklets can be difficult, so the editor helps you to make edits and test them.

When you click the Bedit bookmark a new window should popup that looks something like this:


Click "Populate" to generate sample bookmarklet code.  Then, in your browser, create a new bookmark, and paste the code from Bedit into the URL.  The sample bookmarklet simply sends you to a page, depending upon which day of the month it is.

Some bookmarklets are WAY more complicated.  For example, check out www.supergenpass.com.  If you copy the "URL" bookmarklet code and paste it into Bedit, you can parse the code into (slightly) more readable javascript, make some changes, then run it from within Bedit!

Right click the bookmarklet (this one is from www.supergenpass.com):
Copy the entire entry in the URL field:

And paste it into the Bookmarklet Editor window: 

Click "Run" to test it: 

Editing it in its compressed form is difficult, so parse it first:

---

At the risk of confusion and paradox, the URL code for the bookmarklet editor is below; feel free to copy it and paste it into the Bedit window...

javascript:
W8=open('','B','width=400,height=350,resizable');
W8.focus();
with(W8.document){
write('
<html>
<body bgcolor=\'#CCCCCC\'>
<script>function setTemplate () {
var myX=this.document.getElementsByTagName("textarea");
/* var myText=document.body.outerHTML;
myText=myText + "boo";*/
var myText="javascript:(function(){
var today=new Date();
var dd=today.getDate();
window.location.assign(\'https://www.blueletterbible.org/Bible.cfm?b=Pro&c=\'+dd+\'&t=NIV\');

}
())";
myX[0].value=myText
}
function setX(){
var myX=this.document.getElementsByTagName("textarea");
myX[0].value=p4rse(myX[0].value)
}
function resetX(){
var myX=this.document.getElementsByTagName("textarea");
myX[0].value=colap5e(myX[0].value)
}
function colap5e(v){
v=v.split("\\t").join("");
v=v.split("\\n").join("");
v=v.split(" ").join(escape(" "));
v=v.split("\'").join(escape("\'"));
v=v.split(\'"\').join(escape(\'"\'));
v=v.split("\\r").join("");
return(v)
}
function tabMe(s){
var reg = /[\%7D\%7B]/;
var sa = s.split("\\n");
var isfor = /^for/;
for(var i in sa){
if(!reg.test(sa[i])&&i!=0&&!isfor.test(sa[i])){
sa[i]="\\t"+sa[i]  
}

}
sa[0] = sa[0].replace(/(javascript:)([\\S ]+)/,"$1\\n$2");
s=sa.join("\\n");
var r = s.replace(/for[\(]([\\S ]+%3B)[\\s]+([\\S ]+%3B)[\\s]+([\\S\)]+%7B)[\\s]+/g,"for($1$2$3\\n");
return(r)
}
function p4rse(v){
v=v.split("%3B*%2F").join("**%2F");
v=v.split("%3B").join("%3B\\n");
v=v.split("**%2F").join("%3B*%2F");
v=v.split("%7D").join("\\n%7D\\n");
v=v.split("%7B").join("%7B\\n");
/*  Parse Comments */
v=v.split("*%2F").join("*%2F\\n");
/*  Parse Tags */
v=v.split("%3C").join("\\n%3C");
v=tabMe(v);
v=v.split(escape(" ")).join(" ");
v=v.split(escape("\'")).join("\'");
v=v.split(escape(\'"\')).join(\'"\');
/* v=v.split("\\n\\n\\n").join("\\n");*/
return(v)
}

</script>
<center>
<form>
<textarea style=\'width:100%;
height:90%\' name=X rows=30 cols=34 wrap>javascript:
</textarea>
<p>
<input type=button value=Parse onclick=setX()> 
<input type=button value=Compress onclick=resetX()> 
<input type=button value=Run onclick=opener.location=X.value> 
<input type=button id=populate value=Populate onclick=this.disabled=true;
setTemplate()> <a style="font-size:.75em" target=_new href="http://goo.gl/3t2EjH">08.27.2014</a>
</form>
</center>
</body>
</html>');
setTimeout("W8.focus()",0);
void(close())
}

Sunday, January 13, 2013

More Dropbox Fun

I recently found myself in need of a file from Dropbox on my home/family computer.  But there's a different Dropbox account setup there...

So, I found out that it is possible (on Linux, anyway) to have more than one Dropbox account running at once; read on for details:



Adapted from here:


Install the primary Dropbox account as you normally would, then, to do the second one:
mkdir ~/.dropbox-altHOME=~/dropbox-alt dropbox start -i
You may have to do this several times to get it to work. I found that it helps to close the first Dropbox instance. Eventually, the GUI will ask for the account information and setup the second account. Note that the Dropbox folder will reside by default within your .dropbox-alt directory; leaving it there is probably a good idea.

Once you have setup the second account, you can create a symbolic link to the new Dropbox folder in your /home directory:
ln -s ~/.dropbox-alt/Dropbox/ ~/Dropbox-ALT
The primary installation of Dropbox will run on boot, but to get the second one running, you’ll need to create a script. I like to create mine inside ~/.dropbox-alt:
#!/bin/bashHOME=~/.dropbox-alt ~/.dropbox-alt/.dropbox-dist/dropboxd &
Then, since I'm running gnome, I just put that script in gnome-session-properties to start on boot.

Tuesday, March 6, 2012

Google Docs Keyboard Shortcut for the Equation Editor

I love Google Docs, and the equation editor, though far from perfect,
is pretty handy. Except for the fact that Google didn't create a
keyboard shortcut to activate it.

That means, if you want to insert an equation, you have to use the mouse.

Fortunately, Google Users are resourceful. One such user has created a
script that creates a shortcut-like function in Chrome:
http://goo.gl/7vTg5

Wherever you want an equation, type two dollar signs, and the equation
editor pops up. When you're done with the equation, press Tab.

Wednesday, February 22, 2012

Setup your own Dropbox with Unison

Using Unison in Linux

This does seem to work pretty well. I haven't set it up as a service anywhere, so I have to run it from the command prompt. But, once it gets going, it is quick.

Install Unison on two computers (server and client); uses ssh, so that needs to be installed, too. The version of Unison on both computers must be the same.

http://www.seas.upenn.edu/~bcpierce/unison//download/releases/

Intall OCaml (http://caml.inria.fr/)
sudo yum install ctags-etags ocaml
cd to the unison source directory, then:
make UISTYLE=text
./unison -version
mv unison ~
cd ~
mv unison .unison/
 
Now that the code has been run, the .unison/default.prf has been created; edit (on the client):
# load the common preferences
include common
addprefsto = common
label = default profile
#root = source
#root = /home/username/Desktop/Unison

#root = source2
#root = source2
#root = ssh://login@host.com/Desktop/Unison
#root = ssh://login@host.com/Desktop/Unison

#path = path to sync
#ignore = path to NOT sync

Also on the client, in your home directory, create the .unison/common file:
# Unison preferences fileauto=truebatch=truesshargs = -Ccopythreshold = 1000killserver = truecopyquoterem = trueconfirmbigdel = falsemaxthreads = 5perms=0times=truesilent = true#group=true#owner=trueprefer=newer#crontab -e#*/30 * * * * /usr/bin/unison <profile> &> /dev/null
Use the default.prf file as a template to create a file for your needs (ie "backup.prf"):
# Unison preferences
include common
label = my backup
root = /home/username-on-client
root = ssh://username@domain//media/path/to/destination
path = Name-Of-Directory
This is the commandline I use on the client:
unison backup -auto -ui text
If it isn't working, create a logfile:
unison backup -auto -ui text -logfile unison.log
Once you're happy with it, create a cron job (crontab -e):

*/30 * * * * /path/to/unison backup &>/dev/null
(Don't forget to restart the crond daemon: service crond restart)

You can also use incrond / inotify to call the script on filesystem changes (as opposed to time-based cronjobs.)

[Windows version available here: http://alan.petitepomme.net/unison/index.html]

FYI, to transfer within the same system:
unision -batch <source> <dest>

Advanced Unison Settings

Turn Bluetooth and Wi-Fi on/off automatically in Cyanogenmod 7

Hard little gem to find. If there's another way to do it, I couldn't find it.
Create a Power Control widget, and change the Power Events settings at the bottom of the settings screen.  You can set Bluetooth and Wi-Fi to enable/disable automatically when the charger is connected/disconnected.  (Several other settings are available here, as well, but these are the only ones I was looking for at the moment...)

You do have to save the widget, but you don't have to actually KEEP it, by the way. Deleting the widget from your homescreen doesn't disable these settings.

Monday, February 20, 2012

Dropbox on Fedora 16 Headless

(Some of this came from wiki.dropbox, but I can't find it there anymore...)

AS A USER, NOT ROOT, ssh to the server (without X11 forwarding), then:
echo DROPBOX_USERS="<insert user name here>" > /etc/sysconfig/dropbox.conf 
Fix file permissions: 
chmod 0644 /etc/sysconfig/dropbox.conf 
IN USER'S HOME: 
wget http://www.dropbox.com/download/?plat=lnx.x86_64 
Extract:
tar -xzvf dropbox*.tar.gz cd .dropbox-dist ./dropboxd # DO NOT HAVE X11 FORWARDING ENABLED when you run dropboxd
The first time it is run, it will ask you to visit a link to activate; copy the URL and visit in a browser on your desktop (doesn’t have to be on the server.) Once activated, in the terminal: 
^C to close dropboxd 
cd /lib/systemd/system 
Edit dropbox.service, and insert the followingUPDATED 3/31/2012
[Unit]Description=Dropbox
DaemonAfter=syslog.target network.target nmb.service
[Service]
Type=forking
#PIDFile=/var/run/dropbox.pid
EnvironmentFile=/etc/sysconfig/dropbox.conf
ExecStart=/sbin/runuser -l <USER> -c "~<USER>/.dropbox-dist/dropboxd&"
[Install]
WantedBy=multi-user.target
Enable the service for autostart and start the Dropbox service:
systemctl enable dropbox.servicesystemctl --system daemon-reloadsystemctl status dropbox.service
systemctl start dropbox.servicesystemctl status dropbox.service
To disable the service:
systemctl stop dropbox.servicesystemctl disable dropbox.service

Connecting an Android phone to restricted.utexas WiFi

EAP method: PEAP
Phase 2 authentication: MSCHAPV2
Identity: Your EID
Anonymous Identity: anonymous (Believe it or not, this matters!)
Password: Your EID Password