Friday, July 20, 2012

Fixing skype

I use Ubuntu but I use cairo-dock and gnome-session.
 One issue has been that skype doesn't leave any way to bring itself back up if you click the "x" after launching it. It should leave an icon in the system tray but doesn't.

So I found a script that when relaunching skype instead of starting a second instance simply raises the existing instance. Simply replace the regular skype launcher with this.

#!/usr/bin/env python
import dbus
import sys
import os

try:
    # Try and set skype window to normal
    remote_bus = dbus.SessionBus()
    out_connection = remote_bus.get_object('com.Skype.API', '/com/Skype')
    out_connection.Invoke('NAME single-instance')
    out_connection.Invoke('PROTOCOL 5')
    #out_connection.Invoke('SET WINDOWSTATE MAXIMIZED')
    out_connection.Invoke('SET WINDOWSTATE NORMAL')
    out_connection.Invoke('FOCUS')
except:
    os.system("skype")
    sys.exit()

Wednesday, July 11, 2012

Find recently modified files

Something new I just learned. When using find, -mmin -N will find only files modified in the last N minutes.

~$ find . -type f -mmin -30
Will find only files (-type f) modified in the last 30 minutes.

Friday, June 29, 2012

Get rid of annoying Apache warning

For years I put up with Apaches annoying warning on startup about not being able to determine a fully qualified domain name:

Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
I finally looked up how to get rid of it, and despite a few pieces of incorrect advice in forums the solution is to add the following:
ServerName localhost
to /etc/apache2/apache2.conf, or replace localhost with whatever makes sense.

Wednesday, June 27, 2012

Disable upstart/non-upstart services on startup

To disable non-upstart services:
$ sudo update-rc.d apache2 disable

To disable upstart services, create file named <service>.override in /etc/init/ folder that contains the word "manual"


$ sudo sh -c 'echo manual >> /etc/init/mysql.override'

Friday, June 15, 2012

Resolving SVN conflict after directory rename



Renaming a folder with "svn ren oldname newname" causes a conflict error to occur. I was able to resolve the conflict by issuing the following commands found at http://stackoverflow.com/questions/3941291/a-sane-way-to-rename-a-directory-in-subversion-working-copy

svn resolve --accept working -R .
svn commit

Wednesday, May 9, 2012

Protecting local web folders

This posting is something I had put on my server at some point: 

I maintain a multi-user Linux server and the users can put content up on this server under their own public_html folders.

 I set up a script so users could password protect their folders from the web, which worked but other local users could still see each others work when they logged in locally via ssh.

 I found that by setting the permissions for public_html to 750 I could protect their work from other local users. To allow Apache to still see into their folders I added the apache group (www-data on my system) as the group owner of the public_html folder.

Fortunately, you can use wildcards for directory names in Linux. So in the end it was a simple as doing the following (as root user):

~$ chmod 750 /home/*/public_html 
~$ chown :www-data /home/*/public_html

Tuesday, April 10, 2012

Fixing screen resolution issues in Ubuntu

About a year ago I got a new Dell laptop with integrated Intel video card. Beginning with Ubuntu 11.10 there was an issue. It would boot up and set the screen resolution to the maximum (1920x1080) but it would give me no options to reduce it. I use my laptop with projectors all the time, but I was unable to mirror my output because all I could get was 1920x1080. So I've been using Mint, thinking the next version would fix it. No dice though. So I dug in and figured out my issue. First of all, Ubuntu no longer creates an xorg.conf file in the /etc/X11 folder. However you can put a config file in there and Ubuntu will use it. So in order to get Ubuntu to generate an xorg.conf file, you run:
tward $ X :1 -configure
:1 specifies the display to use, :0 is default but you are (probably) already using that one. This should put xorg.conf.new in your home folder. Now you need to add modeline options to it, these tell it what to do with the monitor at various resolutions. To create these modelines use cvt (the etc.. part is my own).
tward $ cvt 800 600
# 800x600 59.86 Hz (CVT 0.48M3) hsync: 37.35 kHz; pclk: 38.25 MHz
Modeline "800x600_60.00" 38.25 <...etc...> 624 -hsync +vsync
Do this for each resolution you want to have and copy the lines into xorg.conf in the Monitor section for Monitor0.
Section "Monitor"
  Identifier   "Monitor0"
  VendorName   "Monitor Vendor"
  ModelName    "Monitor Model"

  Modeline "1280x1024_60.00" 109.00 <...etc...> 1063 -hsync +vsync
  Modeline "1024x768_60.00" 63.50 <...etc...> 798 -hsync +vsync
EndSection
Finally, you need to (maybe not??) add the resolution strings to the Screen section, Display SubSections where applicable:
Section "Screen"
        Identifier "Screen0"
        Device     "Card0"
        Monitor    "Monitor0"
....
        SubSection "Display"
                Viewport   0 0
                Depth     1
                Modes "1920x1080" "1280x1024" "1152x865" "1024x768"
        EndSubSection
 EndSection
Reboot, or otherwise restart X and everything is now working.

Friday, April 6, 2012

19 ffmpeg commands for various things

This site has a bunch of simple, cool things ffmpeg can do, though as with everything I've ever tried in ffmpeg, they don't all work as given...

  • Turn a video in to a series of image files or vice-versa
  • Encode for various devices: PSP/iPod etc..
  • Rip audio
  • And of course, all kinds of conversions


http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

Wednesday, April 4, 2012

Miles Davis, Kind of Blue

I don't normally post non-Linux related stuff on here, but I had to post this...
I tried to create a "radio station" on Pandora by typing in "Kind of Blue" and got two results for composers I have never heard of, but NO Miles Davis!

Are you kidding me? Arguably the most famous Jazz album ever created. Possibly the best selling Jazz album of all time. Considered by many to be the best Jazz album of all time. Considered to be one of Jazz' masters, Miles Davis's masterpiece. And Pandora doesn't know it?

Wow, maybe their servers are being worked on...

Wednesday, March 14, 2012

Force removal of broken packages

If you try to install a package and are missing dependencies, apt-get will not let you remove it because it is an an inconsistent state.

tward $ sudo apt-get remove tinyos-2.1.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 avr-libc-tinyos : Depends: avr-gcc-tinyos but it is not going to be installed
 avr-tinyos : Depends: avr-binutils-tinyos but it is not going to be installed
              Depends: avr-gcc-tinyos but it is not going to be installed
              Depends: avrdude-tinyos but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Apt-get -f install does not fix the problem.
A solution is to remove the package with dpkg, then do the repair.

tward $ sudo dpkg --force-depends --purge tinyos-2.1.1 

tward $ sudo apt-get -f install

Tuesday, February 28, 2012

Find what apt-get installs

Some packages install programs whose names are not obvious, such as air-crack and some put files in non-obvious locations such as apache2.
After installing, you can determine what files are installed and where with the following command:
dpkg -L <packagename>


tward $ sudo dpkg -L afflib-tools | head -5
/.
/usr
/usr/bin
/usr/bin/afcat
/usr/bin/afcompare

Friday, January 27, 2012

Using -exec instead of xargs

Using xargs to pipe results of find into grep has problems if find returns files/folders with spaces in the name.

find ./ -name "*html" | xargs grep "something"


Ends up giving me lots of "file doesn't exist" errors.

Using exec circumvents this problem, although using exec is apparently a less efficient way of doing things.

find ./ -name "*html" -exec grep -H "something" "{}" \;

-H tells grep to always show the filename, otherwise you only get the match.
"{}" represents the filename returned by find.
\; I'm not sure what this is, but it has to be there...

Update:
I describe a slightly simpler solution in this posting.

Friday, January 20, 2012

Open MS Office documents with MS Office through nautilus

See reply below for updated solution.

The general form is: wine "C:\path\to\irfanview" '""Z:%f""'

So for MS word for instance:
  Right click on .docx file and select open with-> custom
  Enter the following: 


wine "c:\Program Files\Microsoft Office\Office12\WINWORD.EXE" '""Z:%f""'


The Z and %f have to do with the fact that wine apps locate Linux files through the virtual z: drive, and %f inserts a filename.