Friday, October 11, 2013

Working around absurd copyright restrictions

Some parts of copyright law are just downright stupid. For example, if I make a video of my baby reacting to TV or music playing on the radio, I may not be able to make that video/audio available online (on, e.g., YouTube) due to potential copyright infringement.  This could be a problem for many parents and others.

Thus I propose the following:  build a browser plugin that will take the potentially infringing audio stream (or any stream for that matter) and scramble it via encryption or any other method prior to upload.  This should make infringement detection very difficult if not impossible.  Then, the plugin will decrypt the audio stream as the video is played back.  Sharing can be accomplished in a way that allows the decryption key to be safely passed between plugin users.

Wednesday, September 12, 2012

Regain control of a rogue XCP Server

In the past year, I have constructed a small private cloud from four Core-i7 machines and Xen Cloud Provider.  Recently, one of my servers suffered filesystem corruption such that somehow its root password was mangled.  If you are lucky enough to have physical access to the machine, then you can try this procedure, which I must note is not much different than that for any normal Linux box, except in the specifics of the bootloader.
  1. Boot your server as usual, but you need to get to the SYSLINUX prompt by pressing the <shift> key after BIOS POST.

  2. You will then see the Syslinux boot: prompt which is asking you for which kernel it should boot.   You need to then type menu.c32 <enter>.  Be warned that a hidden boot timer is ticking at this prompt, but it's reset every time you type a key.

  3. You will be presented with a menu for booting into e.g., regular XCP, safe mode, etc.  Select the first entry (xe) with the cursor keys (it should start on that entry anyway), then press <Tab> to edit the boot parameters.

  4. You should see something like the following:

    append /boot/xen.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M console= vga=mode-0x0311 --- /boot/vmlinuz-2.6-xen root=LABEL=root-mlbdhhzz ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash --- /boot/initrd-2.6-xen.img

  5. You want to insert the single keyword for the dom0 kernel like so:

    append /boot/xen.gz dom0_mem=752M lowmem_emergency_pool=1M crashkernel=64M@32M console= vga=mode-0x0311 --- /boot/vmlinuz-2.6-xen single root=LABEL=root-mlbdhhzz ro xencons=hvc console=hvc0 console=tty0 quiet vga=785 splash --- /boot/initrd-2.6-xen.img


    I also removed the quiet and splash options so that I can see if anything strange is happening during the boot process.

This should drop you at a single-user root prompt from which to do your analysis and repair.

YMMV!

Saturday, July 2, 2011

Roaming in Eilat

I have been traveling in Europe and Israel recently, and I decided to bring my Pantech Crux from Verizon, mostly to use as an alarm clock!  In Paris, Greece, Tel Aviv, and Jerusalem, I could not get any kind of signal.  I expect that this is because these places use GSM, which operates on a different frequency than CDMA in the States.  In addition, I was not aware of any relationship between Verizon and local international providers.

The Crux is a CDMA-only phone.  The designers did not think that the phone would be used outside of the US (since it basically does not work), thus they didn't provide an option to change the date and time manually!  The date/time is changed according to the US timezone in which coverage is being provided. For the first few weeks of my trip, I was setting the alarm 6 or 7 hours behind, because the phone was stuck on EDT.  When I arrived in Eilat, one of my alarms triggered and I didn't understand why... until I noticed that the time had changed and I was getting a roaming signal!  I dared not dial anyone for fear of a $1.99/min fee.

It turns out that Verizon does have CDMA towers in over 40 countries, Israel being one of them.  They claim that they provide service in Tel Aviv and Jerusalem, but that did not happen in my experience.

Anyway, if you own a CDMA phone from Verizon, at least you can rest easy... Just get to a CDMA tower in the closest country to you, and reset your alarms!

Sunday, December 19, 2010

Web Link Auto-Updating

Every so often, people will come across outdated links on a web page. It seems to me that this situation is mostly avoidable, or at the very least, we have the capability to resolve it to most people's satisfaction. Why not have a server-side script that checks, on a regular basis, the availability of the links in your web pages? If a link is unavailable for a predefined length of time, it will be made to point to a recently cached copy, and the webmaster (maybe you) will be notified. We could customize the script to go to Google's cache, archive.org, or if there is space on our server, a local cache.

One difficulty with this scheme is deciding when to replace the "cached" link with the original again. If we do this automatically based on the original link becoming available, we run the risk of that link pointing to a page that is significantly different than the one that was cached. We could decide on a metric of difference, and maintain the link to cached content if the metric exceeds a threshold. This would still require human intervention at some point, but would give webmasters some breathing room.

Doing this manually for sites of moderate to large size might be feasible if we observe that the population of link targets do not change significantly or go dark more than x days per year.

Saturday, September 18, 2010

Optimization in R

I recently performed this computation in R:

stats.irreg <- mclapply(firsts.irreg, function(x) list(means=sapply(cd(x), mean), meds=sapply(cd(x), median), sds=sapply(cd(x), sd), cvs=sapply(cd(x), cv)), mc.cores=2)

This iterates over a list of sublists of vectors (firsts.irreg), each vector being a time series. For each sublist a list is returned with the means, medians, stddevs, and c.o.v.s of the vectors in the sublist. I claim that R is doing much more computation than necessary. In this case, the code that reads 'means=' is computing means of each vector and 'sds= 'is computing standard deviations of each vector. The code that reads 'cvs=' is computing the coefficient of variation of each vector, which is the standard deviation divided by the mean. Thus, R will compute the mean and stddev of each vector twice. Is it possible or even desirable to have a language/interpreter/compiler recognize this and optimize it, or should it always be left to the programmer?

Wednesday, April 7, 2010

Auto EPS Conversion in pdflatex

I recently decided to start using PDF figures in my thesis instead of EPS and compiling my TeX code directly to PDF. This requires that you have the perl script 'epstopdf' installed on your system, as well as ghostscript and the associated machinery. The TeX package "epstopdf", combined with usepackage[pdftex]{graphicx} will auto convert any EPS figures used in your document to PDF. The actual conversion works wonderfully. There is a snag however, as described by the author of the package: even with TEXINPUTS set correctly, the 'epstopdf' script cannot find figures located in nested subdirectories.

A solution upon which I settled was to modify the script and put it in my local path before the real epstopdf (which is usually in /usr/bin). The trick is to use kpsewhich to scan all the associated TeX directories, including those recursively specified in TEXINPUTS. The fix is as follows:

Make a copy of 'epstopdf', and find the following lines in your new copy:

@ARGV &gt; 0 or die errorUsage "Input filename missing";
@ARGV &lt; 2 or die errorUsage "Unknown option or too many input files";
$InputFilename = $ARGV[0];

and change the last line to


chomp($InputFilename = `kpsewhich $ARGV[0]`);

This will prepend the correct path to InputFilename as found by kpsewhich.

So far this works like a charm on all my linux distros (RHEL and Ubuntu). YMMV!

Thursday, September 13, 2007