If I want to save a file, but make sure to not overwrite files, and instead append a number to the end of the file name using Python I may want to write something like this:
I spent more time sorting out a problem than I should have today. I was trying run some scripts from a cron job, they weren't running. They ran fine when run outside of cron, that is, they ran fine on their own or when I manually ran them, but the moment I tried to run them from cron they didn't work. My precise situation was a bash script that was calling some python scripts and some relative path references in the python scripts were breaking. I eventually realized that files were being created in my home directory that were supposed to be created in the directory containing the python scripts. The problem was that the directory that cron runs out of is different from where I was running it manually. That is, if I had ran "pwd" I would have not received the result I expected.
The fix was to "cd" into the the directory I wanted to run the scripts from at the beginning of my bash script. The result was something like this.
Here is a python script which will list all the URLs associated with a YouTube user's videos
Something to remember, if a service isn't working right, check to see how much disk space is left, if it is zero, then that could be the cause of the issue.
This Tampermonkey script allows you to hide Facebook posts based on their content.
Update: This does seem to result in a performance hit.
I was capturing some digital video through firewire on Ubuntu 12.04 with Kino and there was no sound. Starting Kino with this comman remmedied the situation.
The error I was receiving was this:
I had some problems with the Libreoffice 22.214.171.124 spellchecker and grammar checker in Writer today. I tried to install the LanguageTool extension but it was giving me permission issues that I wasn't able to quickly fix. I had upgraded from an earlier version of Libreoffice today and I read that the old user profile might be causing an issue so I also removed ~/.config/libreoffice to no avail. I then removed and purged libreoffice-* and reinstalled. I was then able to install the language tool, as well as the hunspell-en-ca (Canadian English) Ubuntu package. As of this evening, I have a very nice Libreoffice installation, complete with grammar and spell checking! On a side note, I do recognize that this was more troublesome than it should have been, spell checking and grammar checking should be pretty standard, and something that every user makes use of, including those less tolerant than me. But, what can I say? Beggars can't be choosers, it's libre and gratis. Lastly, afterthedeadline.com is a language tool I use for this blog, and it works pretty well. It can also be used with Libreoffice but I am hesitant to do so. It is a cloud service that checks your language use, and since unlike my blog, usually the content I produce in Libreoffice is private it constitutes a privacy/security threat. It is possible to run your own After the Deadline server but that is a fair amount of effort for spelling and grammar and in addition it takes up a fair amount of system resources.
Update: Strangely, a friend just asked me about this, a few days after I had this problem. I supplied him with some instructions that I think would be useful for people who might end up here. The following should probably get you a good Libreoffice install. I haven't tested them, but they should be pretty close. There are some unnecessary commands here, but, I'm just sort of choosing the nuclear option to kill an ant.
Then install this plugin http://extensions.libreoffice.org/extension-center/languagetool and restart Libreoffic
e.Update: In Ubuntu 13.04 with Libreoffice 126.96.36.199 and Language Tool 2.1 I needed to install libreoffice-java-common in order to install Language Tool.
I needed to apply a recursive chown command to my home directory today. The problem is that I have a very large external file system that is mounted in my home directory, one that must remain mounted. I did not want the chown to be applied to the remote file system and chown doesn't have functionality built into it to perform advanced recursive actions, like, recursive except with x. Then I remembered the -exec switch on the find command and realized that -exec is a great way to get recursive functionality for any command that your want to run with advanced recursive functionality. In my case, I used the -mount switch to limit the execution to the local filesystem only, but other regular expression conditions, or other filtering mechanisms could be used too! This is an important and flexible lesson. It's really quite obvious in hindsight, and probably obvious to a Linux sysadmin guru, but in any event, here it is.
In continuation of the troubles I had in my last post, I finally found a stable way to create a web app window in Ubuntu, and the solution was available all this time, I just didn't know it. In Chrome there is built in functionality for application shortcuts as seen here that accomplishes everything that I wanted. With one caveat however, it does a poor job at choosing an icon leading to a pixelated mess. In order to fix the icon issue, I had to create a custom launcher of sorts which complicated the matter. For this particular issue I decided to make a video: I know the goals of the built in functionality heading for Ubuntu 12.10 and the goals of Fogger are to have even greater desktop integration than what this offers, but this already has two major benefits for me. One being the increased screen real estate that occurs because of the removal of the address bar and the tabs, the result is even better than Chrome without the system title bar option enabled. But even more important, workflow is substantially improved because instead of navigating through mounds of browser tabs I can use the navigation tools which are built into Ubuntu, such as being able to ALT+Tab, or being to use the Compiz expose, or any of the other window switchers. Certainly there is limited tab navigation capabilities built into Chrome but none is as superior to the OS navigation. The OS navigation is superior because from the OS switching tools I can always immediately switch to my desired destination without other steps. Consider these two examples. One is where there is no web application functionality, I might ALT+Tab to my browser window, then I would have to perform a second operation to get to the desired tab if I have not by luck landed on it. The second situation is where the web application functionality exists, in this scenario I can ALT+Tab immediately to where I am trying to go without the need to select a tab after activating the web browser. And to me, this is an enormous benefit.
This will be very quick, I cannot dedicat much time to this sort of thing at the moment, I have already spent too much time on it. But, as I have shown before I have interest in being able to delete old Facebook wall posts. This is because conversations we have in person are largely ephemeral and I think Facebook should be too, or at least have the ability to be.
To show where the script goes I have include the image below (but of course you'd be on Facebook):
This script is to be run when you are on the Facebook "activity log" page. Within that page you could select, for example,
"All," "Your Posts," "Post by others, etc"(I can only confirm it for "your posts," if it comes across an item which you can't delete it will not work) in order to have a bit of extra control over what is deleted.
This post has been brief, details have been left out, but I did want to share this code so that it is out there in case anyone wants to build on it. If I had infinite time I would put this in a Greasemonkey script, and wrap it into some sort of easy to use user interface.
Also note, you need to scroll down in your activity log, and reveal all the posts which you want to be deleted in order for them to be deleted. The script does not automatically load them in for you.
Lastly, how do you know when the script ends? It crashes. hehe
I thought I'd share my recent disaster story with the internet so that perhaps someone else can benefit from my misfortune.
I was playing around with a PXE server a few nights ago so that I could host Linux ISOs on the LAN and boot off them so that I would not have to keep on making various USB Live CDs. Since this is a common occurrence I figured this would be a fruitful endevor.
I had set up the server and it was time to test it out. I shutdown my Thinkpad X60 tablet and attemtted to modify the BIOS for network boot. I then realized that I had a password on there from probably about 5 years ago, a password which I no longer remebered. I thought no problem, I will just pull the BIOS battery and the password would be removed, no problem.
I open up the machine, pull the battery and plug it back in and boot the machine. To my horror, I recieve a message to the effect of, "your device has been tamprered with please enter the BIOS password to continue." That is, the BIOS password I was attempting to remove because I no long remember it. Or in other words, I am locked out of my own machine at the hardware level
Of course I have queried the internet on a possible remedy to my situation but to no avail. I saw one thing about being able to solder some wires to a particular chip and read the password off it via a secondary computer's serial port in combination with a few other minnor electronics but my model was not listed in this tutorial and I could not find the chip upon inspection of the motherboard. I also read that I could have the motherboard replaced to remedy the situation. However, neither of these two solutions were time or money efficient for me and my life right now.
I was quite surprised that this happened but I am glad that my computer savvy friends have not said 'well duh' when I tell them the story. It was an extremely embarassing mistake, though it is hard to blame myself since it would appear that many people too were not familiar with that behaviour, though I am sure this could have been obvious to Thinkpad technicians.
What I do not fully understand is what purpose does this serve? I mean, I assume people place passwords on their computers to protect the data not the hardware and this feature that I have been caught up in does not accomplish much in the way of protecting my data. In fact, I just finished retreiving my data from the hard drive which was in the machine at the time by connecting it to another machine via a SATA-USB adapter. Doing so did require the encryption key I used to encrypt the drive, so, my data was secure, but this security was not provided by the BIOS. I also suppose, and perhaps this already exists, that the hard drive could be cryptographically paired with security chip on the motherboard, and if that were the case I could see the BIOS password making sense. Or maybe this feature was available and I did not realize it. But keep in mind, this machine came pre-installed with Windows XP, a time where I do not recall encrypted hard drives being common place. It seems to me that I have in vain been permanently locked out of an old, both otherwise perfectly good machine.
Bottom line: Be careful when unplugging the BIOS battery of a laptop!
I ran into some issues with getting Virtualbox to run. I'm not sure why it stopped working, it seems like it might have been because a new kernel was installed, I'm not sure. However, I fixed it, it seems as if I was missing the new kernel headers. Bellow you will find the two commands I think fixed the situation, hwoever, there were a few others I ran in the process of troubleshooting.
For whatever reason every time I have shot a portrait mode video with my Motorola Atrix cellphone. Today the issue came up again and here is the command I finally used with acceptable success.
It isn't perfect, but, it is good enough, I hope this helps
I am using the Omnibar extension in Firefox which gives Firefox a Chrome like search/address/location bar. When I open a new window I want the cursor position to default to this bar. In order to do this, in Firefox I set the default hompage to blank, and when I did that, the cursor was put in the Omnibar instead of on the homepage which was loading
double click "browser.tabs.opentabfor.middleclick" in "about:config" to cause middle clicking links to cause a new browser window to open rather than a tab.