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.
Notes and things that I can't remember when I need them. Mostly technical stuff. Linux-ish. VERY likely things that nobody else will find useful at all. Hence the title...
Monday, June 10, 2013
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:
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:
Once you have setup the second account, you can create a symbolic link to the new Dropbox folder in your /home directory:
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 -iYou 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.
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/)
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
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 ocamlcd to the unison source directory, then:
make UISTYLE=textNow that the code has been run, the .unison/default.prf has been created; edit (on the client):
./unison -version
mv unison ~
cd ~
mv unison .unison/
# 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:
Use the default.prf file as a template to create a file for your needs (ie "backup.prf"):# 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
# 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 textIf it isn't working, create a logfile:
unison backup -auto -ui text -logfile unison.logOnce 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.
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.
Subscribe to:
Posts
(
Atom
)





