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.