This is a simple Python implementation. Note the global variables p and a should in general be re-generated each pass. p is any prime and a is the primitive root of p.
This is a simple Python implementation. Note the global variables p and a should in general be re-generated each pass. p is any prime and a is the primitive root of p.
...
Something I always missed from Foobar2000 is the option to "Stop playback after current song"
For some reason it never occurred to me it would be trivial to write an AppleScript to mimic this for iTunes..
tell application "System Events"
set cur_app to name of the first process whose frontmost is true
set visible of process cur_app to false
end tell
...
After looking for a way to import Python modules when given a valid filepath I came across a description of a technique to do so here.
What I did not like about this approach was the use of null_module. In his approach you needed to have a module called null_module somewhere in your PYTHONPATH. This was then cloned and the information about the actual module you wish to report overwrites this module. In short, he was using null_module as a skeleton module for the import. This is unnecessary.
To do the entire import in a much nicer way you can simply do:
...
This is going to be mostly a code post.
First thing we need is a method of getting the coordinate of elements in the document. Here is a function I created to do that.
/**
* Get the offset coordinates of the element.
* @param {Object} element The element.
* @return {Object} An object with four properties named x1, x2, y1 and y2 containing the elements left, right, top and bottom edges respectively.
*/
function getElementPosition(element) {
var elementX = 0;
var elementY = 0;
var elementW = element.offsetWidth;
var elementH = element.offsetHeight;
while (element.offsetParent) {
elementX += element.offsetLeft;
elementY += element.offsetTop;
element = element.offsetParent;
}
elementX += element.offsetLeft;
elementY += element.offsetTop;
elementW += elementX;
elementH += elementY;
return {x1: elementX, y1: elementY, x2: elementW, y2: elementH};
}
...
During my recent struggle with the JavaScript canvas object I was looking for a method to draw ellipses. Originally I was trying to use the arcTo() and even got desperate enough to have a quick play around with the bezierCurveTo() and quadraticCurveTo( ) functions before the obvious solution dawned on me.
In the event anybody else wastes their times looking for a way to do this try the following:
var e = document.createElement("canvas");
document.body.appendChild(e);
...
I want to run the unittests verbosely, so you can see which test is running (the function name, or if you have a one-line docstring, it displays that), instead of the usual "..E..F." output.
There are two ways, the first is to construct a test-suite using TestLoader, pass it to TestTextLoader(verbosity=2):
suite = unittest.TestSuite([
unittest.TestLoader().loadTestsFromTestCase(test_tvnamer.test_name_parser),
unittest.TestLoader().loadTestsFromTestCase(test_tvdb_api.test_tvdb)
])
# for one test, you can do:
# suite = unittest.TestLoader().loadTestsFromTestCase(test_name_parser)
...
Whenever someone complains about a new version of a bit of software, my general response is "you don't have to upgrade".
For example, complaints about Vista can generally be countered with "Well, Windows XP still works fine.."
Where this argument entirely falls down is when an upgrade is forced, but there is pretty uncommon (online portions of video-games, instant messaging applications)..
...
After taking significant time to be lazy & forgotful I have reconfigured the apache to run the nullnetwork image paste tool again (available at http://imagepaste.nullnetwork.net/). All are free to contribute to the gallery.
This post on how to install the LLTD is largely ripped off from http://www.howtoforge.com/installing-the-lltd-protocol-responder-for-linux-on-debian-lenny and made a bit more direct for those that just want to make it work and not pay attention to what you're doing! Like me!
So let's dive right in.
mkdir lltd cd lltd wget http://download.microsoft.com/download/b/8/e/b8eee444-f8d5-4b8b-aa3d-2f19bf19ac72/Rally-LLTD-PortingKit.exe unzip Rally-LLTD-PortingKit.exe sudo apt-get install linux-headers-`uname -r` build-essential
...
/alias figlet /exec - -o echo $0-| figlet -w 60 | awk -F% 'function randint(n){return int(33+n * rand())} {printf("\x03%s%s\n",randint(12),$1)}'</pre class='code'>
Combining the joys of shell scripting, figlet, irssi colour escape codes and two different kind of escape sequences, you can achieve the following...
...