tag:blogger.com,1999:blog-81489332167027282912024-02-01T20:29:01.130-08:00def dayCoder(self):some stuff about not being a particularly good programmer, about languages, about testing, about Apple, about tech, and anything else I fancy adding.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.comBlogger143125tag:blogger.com,1999:blog-8148933216702728291.post-29762705165077056122016-05-07T09:20:00.000-07:002016-05-07T12:52:11.141-07:00ReassuringA few years ago, when was getting into Python, I wrote an XML parser. It's slow and fairly terrible at namespaces and doesn't have any proper unit tests, but it's pretty easy to use. Of course, I shouldn't have written it at all, but I learned to code before Stack Exchange was a thing. I didn't know that I could find all the answers from smarter people there. Or even that there were some built-in Python things for XML.<br />
<div>
<br /></div>
<div>
I'm still using that parser, which has its own sort-of-XPATH-ish searching, which was written before I knew that XPATH was a thing.</div>
<div>
<br /></div>
<div>
When I wrote it, I'd never really written a parser for anything particularly complex or vague.</div>
<div>
<br /></div>
<div>
To parse, it uses a class called StringReader. I've never been happy with the name, but haven't spent any time trying to figure out what it should be called.</div>
<div>
<br /></div>
<div>
Today <a href="http://www.cocoawithlove.com/blog/2016/05/01/swift-name-demangling.html">swift-name-demangling</a> popped up in Reeder. It talks about a 'Scanner' class, and shows the .cpp header:</div>
<div>
<br /></div>
<pre class="brush: cpp;">class NameSource {
StringRef Text;
public:
NameSource(StringRef text);
bool hasAtLeast(size_t len);
bool isEmpty();
explicit operator bool();
char peek();
char next();
bool nextIf(char c);
bool nextIf(StringRef str);
StringRef slice(size_t len);
StringRef str();
void advanceOffset(size_t len);
StringRef getString();
bool readUntil(char c, std::string &result);
};
</pre>
<br />
If Python had headers, this is what mine would look like:<br />
<br />
<pre class="brush: python;">class StringReader(object):
def __init__(self, string):
def fwd(self):
def rev(self):
def next(self):
def prev(self):
def peek(self):
def eos(self):
def sos(self):
def reset(self):
def find(self, value):
def checkFor(self, string):
def skipAny(self, valueToSkip):
def skipPast(self, valueToSkip):
def peekAhead(self, length=20):
def getUntil(self, value):
def getUntilSequence(self, value):
def rememberPosition(self):
def restorePosition(self):
def remainder(self):
</pre>
<br />
It's really reassuring that even though I wrote this in the dark (metaphorically at least) there's a significant overlap with same/similar names (peek, next, getString/remainder, readUntil/getUntil, isEmpty/eos). I have more methods. Some look like unnecessary duplicates. I hadn't discovered how to indicate private methods, hadn't discovered properties and hadn't discovered Python naming conventions. I'll have to look into that default length of 20. That looks really odd.<br />
<br />
Given that I this grew organically as I needed methods in my XMLElement class, I'm pretty pleased with it today. I think I'll rename it StringScanner.<br />
<br />
<br />bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-50864760844374767352016-04-25T17:50:00.001-07:002016-04-25T17:50:38.232-07:00Prince. Sadface. What an idiot!The untimely death of Prince has me saddened and confused. Saddened for obvious reasons. Confused by own stupid neglect of my erstwhile fan status. I'm kicking myself that I never quite got around to seeing him live. I'm annoyed that I stopped listening to his music.<div>
<br /></div>
<div>
I was a fan from Around The World in a Day to Diamonds and Pearls. I remember rushing from work to Our Price in a lunch hour the day that Diamonds and Pearls came out, getting back to the office a little late and plying it on my CD Walkman for the rest of the week.</div>
<div>
<br /></div>
<div>
This span, from 1985 to 1991 was what I considered my metal years. I'd buy lots of terrible hair metal on Roadrunner Records. I was into guitars and guitarists that were written about in Guitarist magazine. Nuno Bettencourt and Steve Vai and Joe Satriani and Jennifer Batten and Paul Gilbert.</div>
<div>
<br /></div>
<div>
Astonishingly, I'd have probably bought <a href="https://en.wikipedia.org/wiki/Project_Driver">Project Driver</a> at about the same time as Parade. </div>
<div>
<br /></div>
<div>
You've probably seen the video of Prince's astonishing playing on 'While my guitar gently weeps' with some rock dinosaurs. I don't know if it's true, but I read that this performance was shortly after, and perhaps a response to being absent from a Rolling Stone list of the 100 greatest guitarists. If true, what a fabulous "Fuck You!"</div>
<div>
<br /></div>
<div>
But here's the weird thing: I really liked Prince. I was really into guitarists. I never put these things together. It seems utterly bonkers in hindsight, but I think I know why…</div>
<div>
<br /></div>
<div>
Prince wrote some great songs, arranging and producing them, often playing most of the instruments himself. Guitar was just a part of what he did. Just part of a song. Maybe exemplified by When Doves Cry, where it's pretty much just an intro to the intro. Not a run of the mill guitar solo in the middle of a song in the middle of an album of other songs full of guitar solos. In Paisley Park, it's kind of easy to miss the moments of guitar virtuosity, or forget that it's Prince himself playing them, because they're part of a whole.</div>
<div>
<br /></div>
<div>
Maybe it was a compliment to his song writing and production skills that Rolling Stone overlooked his guitar playing.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-67946863281792152712016-04-01T16:52:00.001-07:002016-04-01T16:52:39.691-07:00Tabs, spaces and alignment.<div>I just read this...</div><a href="http://cocoawithlove.com/blog/2016/04/01/neither-tabs-nor-spaces.html">http://cocoawithlove.com/blog/2016/04/01/neither-tabs-nor-spaces.html</a><div><br></div><div>I agree with it all completely, except the parts I disagree with.</div><div><br></div><div>I agree that I t doesn't matter whether you tabs or spaces as long as you and your team are consistent.</div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0); font-family: 'Helvetica Neue Light', HelveticaNeue-Light, helvetica, arial, sans-serif;"><br></span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0); font-family: 'Helvetica Neue Light', HelveticaNeue-Light, helvetica, arial, sans-serif;">I think my preferences come from coding on actual VT100s an VT220s in the 80s. Physically 80/132x24 monochrome. </span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0); font-family: 'Helvetica Neue Light', HelveticaNeue-Light, helvetica, arial, sans-serif;"><br></span></div><div>I prefer spaces. A space is a fixed unit and a tab is unpredictable. You need spaces in your code, but you don't need tabs. It makes sense to pick just one, and that can't be tabs. </div><div><br></div><div>Where I really disagree though, is that manually formatting and aligning to make the code pretty is a waste of time and effort. Readability is really fucking important. Code is read <i>far</i> more than it is written. To not make the code pretty will annoy or inconvenience readers, including future me. The most valuable tool in making code readable is space. We see this most obviously in left indentation implying or defining scope. It's also good for indicating arbitrary blocks. Or giving a complex line room to breath. </div><div><br></div><div>The other thing that really, really bugs me about this drive for efficiency while coding. I'm not 100% creative coding at full speed the whole time. It's more like crafting or interval training. There's a creative burst, then a period of recuperation. This is when I prettify the code I've just written. There's low cognitive load, pride in a job well done, and I'm ready for the next creative burst. </div><div><br></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);">In monochrome, there's no syntax highlighting. Keys and values, formal parameters and their default values or actual values, names and literals. They all look the same. Maybe pretty code yields more readability in that context.</span></div><div><br></div><div><span style="-webkit-text-size-adjust: auto;">While I'm at it… Comments that add value are fine. Yeah, yeah, they can atrophy, and code should be self-documenting, but a little explanation can make skimming the code a lot easier. Anyone maintaining or reviewing code needs to take responsibility for the comments.</span></div><div><span style="-webkit-text-size-adjust: auto;"><br></span></div><div><span style="-webkit-text-size-adjust: auto;">Lastly, I was intrigued by this post, in which an editor would present code like an outliner rather than just text: </span><span style="font-family: 'Helvetica Neue Light', HelveticaNeue-Light, helvetica, arial, sans-serif;">http://inessential.com/2015/12/21/how_to_solve_tabs_vs_spaces_forever</span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);"><br></span></div><div><br></div>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-80961607326499443132016-03-28T07:30:00.002-07:002016-03-28T11:21:32.073-07:00Misfits and Heroes<div>
I've been trying to figure out why a lot of reasonably well made TV is unwatchable crap. The main problems are poor dialogue and too much exposition (often the source of poor dialogue). i consider both to be dumbing down or condescending. Sometimes it's just poor music (I find a lot of BBC productions have poor/predictable incidental music). There most be more though...</div>
<div>
<br /></div>
<div>
Rob Delaney was on <a href="https://youtu.be/0rCY_iKl_C4?t=242">BBC Breakfast</a> recently. He explains differences between UK and US humour. For professional comedians, there's no difference. We're both as funny as each other. On an every day level though, Brits are funnier than Yanks.</div>
<div>
<br /></div>
<div>
I wonder if this is why I consider New Tricks to be watchable crap, CSI pretty much unwatchable and CSI Miami made me shout at the TV when I tried to watch it. Perhaps the American stuff really does represent relatively humourless everyday interactions and this is simply a cultural difference.</div>
<div>
<br /></div>
<div>
Perhaps this is the difference between <a href="http://www.imdb.com/title/tt1548850/?ref_=fn_al_tt_1">Misfits</a> and <a href="http://www.imdb.com/title/tt0813715/?ref_=nv_sr_2">Heroes</a>. The difference between <a href="http://www.imdb.com/character/ch0064640/?ref_=fn_al_ch_1">Sheldon</a> and <a href="http://www.imdb.com/character/ch0403900/?ref_=tt_cl_t2">Howard</a>?</div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-27431055079842171162015-10-18T16:51:00.002-07:002015-10-18T16:53:51.512-07:00Fanner UkuteleI bought a <a href="https://www.etsy.com/uk/listing/191430667/ukutele-electric-ukulele-bubblegum-blue">Fanner Ukutele </a>via Etsy.<br />
<br />
It's amazing; beautiful; unique. It's also really heavy. I don't think it weighs much less than many fully size electrics.<br />
<br />
I feel bad about this, but I've left it too long to leave a review on Etsy. There's a 60 day limit, that I wasn't aware of, and I really wanted to live with the instrument for a while before leaving feedback.<br />
<br />
Communication with Brian Fanner was superb through the whole process. I asked for something unique, and got exactly that. It hasn't turned out to be quite what I expected, but it's exactly what I asked for. Any issues are purely down to me.<br />
<br />
I wanted a steel string electric ukulele. I'd considered the <a href="https://www.youtube.com/watch?v=QOcMTx4dxNs">Risa LP Tenor,</a> but it's a little expensive, and I wasn't sure if it could be set up as I wanted it.<br />
<br />
The standard Fanner Ukutele uses steel guitar strings (1,2,3,1) with re-entrant tuning GCEA, as on a regular uke. If you fancy one, this is what I'd recommend.<br />
<br />
What I asked for was twofold. First, I didn't want re-entrant tuning. Second, I wanted to drop an octave, making the G *two* octaves lower that a regular uke. I wanted GCEA because my musical brain is limited and transposing (to, say ADF#B) on the fly is beyond me.<br />
<br />
Brian was concerned about the additional tension, and decided to install a truss rod. In order to do that, he needed to make a unique neck-plate (using 4 bolts, not his usual 3). I made some calculations based on the scale length published on Etsy and figured that the strings would be a little loose, but OK. I think the scale length is a little longer though, and they turned out a bit too flappy. Tuning up a tone helped a lot, but I still had the mental problem of transposing.<br />
<br />
The E string had a kink in it at the 4th fret. I'm not sure how. Strings needed to be replaced. I took a gamble on some Ibanez 7-string light strings, and restrung with 4,5,6,7, back up to G. I was worried that they'd be tough to bend, and that they may not sit well in the nut, but they're fine.<br />
<br />
What I have though, I'd hesitate to call a ukulele. It's much more like a small 4-string guitar. It's well suited to blues/punk/rock rhythm. I'm playing it differently to a uke. More power-chords, do a D will be 2-2-4-4 rather than 2-2-2-0 or 2-2-2-4. I'm also finding blues patterns that work well on the ukutele that don't work on a uke.<br />
<br />
The only downside is that it's missing some high-end jangle. I may have to order a standard one for that.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-65457743452920274642014-12-08T05:50:00.001-08:002014-12-08T05:50:16.188-08:00Dropbox can't sync because folder is empty.<pre style="word-wrap: break-word;"><font face="Helvetica Neue Light, HelveticaNeue-Light, helvetica, arial, sans-serif"><span style="white-space: normal; -webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);"> I've had this a few times now, and failed to track it down, resorting to things like clearing the .dropbox.cache, quitting dropbox, restarting, disabling selective sync etc.
I thought that the problem was due to a script I run fairly often, which deletes all log files in all subfolders in a project and also pushes changes to boiler plate code to any folder in the project that currently has a copy. I thought that maybe if I ran this too frequently, while a previous sync was in progress, it would just be too much for Dropbox.
What I've just discovered though, is that the blocking folder, which is empty/deleted in Dropbox, still exists on another machine and that a log file in that folder remains open because the Python script that owns it is still running.
I quit the script and all was well once again.
So maybe if you get this error, check that a file isn't open. If you can't be bothered to track it down, a good old turn-it-off-and-on-again will probably do the trick.</span></font></pre>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-53334688285251573452014-10-31T04:08:00.000-07:002014-10-31T06:20:43.666-07:00"Pride in an immutable state" OR "I'm not homophobic, but..."First, let me say the Tim Cook's <a href="http://www.businessweek.com/articles/2014-10-30/tim-cook-im-proud-to-be-gay">declaration</a> in Business Week was great. I think it can only do good, it brought a tear to the eye.<br />
<br />
But…(here we go!)<br />
<br />
I do have an issue with the word 'Pride'. Note: "I have an issue". It's an opinion, and I may come across as being a homophobic arsehole. That's not my intent. I certainly have had to overcome my own own mild socially acquired homophobia, and there may yet be work to be done to completely eradicate it, but I don't consider myself homophobic any more.<br />
<br />
My homophobia, which probably involved some teasing and name-calling of Neil Si_______ds in junior school* mostly evaporated when I found out that someone I worked with was gay. It's quite possible that I'd worked with other gay people and had no idea, of course. Afterwards, I could perhaps sense that he was more sensitive, more caring and gentle than the average bloke. But if someone found out I was gay - I'm not, but if by some misunderstanding they came to believe that I was gay, they may also suddenly see some signifiers, like being more sensitive, caring and gentle that the average bloke. Those signifiers are mostly bollocks (figurative bollocks, that is).<br />
<br />
Halfway through, I realise this is a bit male-straight/gay. I'm only speaking as a cis-white-male and I only have a little contact with the LGBTQ world. I'm sorry if there's some other way I'm being a dick that I'm not aware of.<br />
<br />
So. Pride.<br />
<br />
I could say "Gay? That's nothing to be proud of.", and you may read that as a sneer of disapproval, such is the written word. So forget that. I'll make a pretentious statement instead:<br />
<blockquote class="tr_bq">
Take pride in achievements, not in a immutable state of your being. </blockquote>
Some examples?<br />
<blockquote class="tr_bq">
I'm proud to be a woman!</blockquote>
<blockquote class="tr_bq">
I'm proud to be an American!</blockquote>
<blockquote class="tr_bq">
I'm a proud Englishman!</blockquote>
You perhaps need to imagine Nigel Farage uttering that last one, and then imagining him saying this instead:<br />
<blockquote class="tr_bq">
I'm proud that my mother had the presence of mind to be in England when she expelled me from her womb, because that has made me better than Johnny Foreigner through no personal effort whatsoever.</blockquote>
And I kind of lump "I'm proud to be gay" in with that. It's obviously not as odious as Farage's Nationalism, but thinking about this a bit today eventually led me to the aforementioned pretentious declaration.<br />
<br />
At first I was trying to think of better words. 'Unashamed', for example, which, while accurate, is intrinsically rubbish because it also suggest shame in the first place. I figured the best word was 'Am'. As in "I am gay" and "I am straight". Just a simple statement of fact devoid of shame or pride. It's also plain that to expect this to be enough in the current world outside certain areas in the West is naiive.<br />
<br />
The Twitter convo has some good points though, one in particular that Gay Pride, as an event, was a protest, but is now a celebration. As a celebration, fair dos. As a protest, given my experience of shedding my homophobia, I think it would be ineffective now. As another pointed out, the apparent need for so many to dress up as village people is kind of self-othering. I think a much more effective protest would be an indication of sameness. A lot of gay people quietly marching and being ordinary would probably make the Cotswolds piss its collective pants.<br />
<br />
I think proper homophobes are terrified of ordinary decent homosexuals, but are actually OK with obviously gay, camp, effeminate homosexuals. The Larry Graysons, the John Inmans, the Maldwyn Pugh's. There's safety there. A homophobe wants to know who's gay so he can, I assume, assume the backs-against-the-wall position in plenty of time. But if their kind-of-mate, who they've been drinking with, or on a rugby trip with … if <i>they</i> turn out to be gay, then FUCK!… <i>Anybody</i> could be gay, how are they going to defend themselves from the legions of gays who might bum them? Aaargh!<br />
<br />
As an example, I know someone who thought Captain Jack in Doctor Who was quite good, and then saw Barrowman being all fabulous on a talk show, and their brain melted. How. Can. He. Be. Gay?<br />
<br />
Let me get back on track...<br />
<br />
The Achievement as a mutable state…<br />
<br />
I think it's fine to be proud of something you've done. Something you've achieved. The level of pride should be dependant on the achievement. I'm proud of having fathered and part-raised two marvellous children. My wife has and continues to do more than half of of the raising part, you know because Patriarchy. Let's face it though, the part-raising is a much greater achievement than the fathering. The fathering amounts to little more than occasionally squirting some semen into a vagina instead of a sock.<br />
<br />
It's an achievement though. And I'm proud of it. At one point I was not a father, and then that state changed, and I was a father.<br />
<br />
The mutable state of a homosexual…<br />
<br />
The being a homosexual isn't, I think we've established, mutable. If you're gay, you're gay and you were made that way. What's mutable is the state of being homosexual being public. Being in or being out of the closet.<br />
<br />
I think this is probably what's meant by gay pride. Not being proud of being gay, but being proud of the achievement of coming out of the closet. It must also be a tremendous relief.<br />
<br />
If you're gay and you have hideous modern parents who are secretly pleased that they have a gay child, because it's one up on the McFarquhars, it's probably not a big deal. It's an achievement, but on the scale of my fatherhood. Don't big up your pride too much.<br />
<br />
There is no shame in being closeted in some circumstances, maybe even in most of the world. Being closeted is a legitimate defence against mental and physical pain. Against torture. Against death. An immutable state of being is a capital offence. That's fucking crazy. If you're in some shitty place, because Nigel Farage's Mum isn't your Mum, then please, take pride in your closeted survival. And if you take a stand despite this, my word, you deserve a statue come the revolution!<br />
<br />
Tim Cook mentions being openly gay with friends and family. It's not a secret, but he's also not broadcasting the fact. He probably felt no need. But today he upped the stakes. Today he broadcast the fact. To misquote Micky Flanagan, now he's out out. He did that because he concluded that this might help someone. This is an admirable thing. Something he has every right to be proud of.<br />
<br />
<br />
Feel free to comment<br />
<br />
<br />
<span style="font-size: x-small;"> *I don't remember doing so, but Neil, if I ever called you a poof or a bender or laughed when someone else did, I'm deeply ashamed, I apologise. I sincerely hope it got better, whether you are gay or not. </span>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-39669342466188091752014-10-29T03:27:00.000-07:002014-10-29T03:30:39.357-07:00Mavericks, Win7, Parallels 10, shift key issue.Since upgrading to Parallels 10, in advance of a planned upgrade to Yosemite*, I've been having trouble with modifier keys when in Remote desktop.
<br />
A few days in, and I'm annoyed enough to DuckDuckGo for a solution.<br />
<br />
The answer was to set Virtual Machine -> Configure -> Options -> Advanced -> Optimize for games.<br />
<br />
I found the answer <a href="http://www.somecodeguy.com/?p=28">here</a><br />
<br />
<br />
<br />
*I'll wait until I have a 2 week break at Xmas, when I can do a full backup, install, test and revert if necessary, without risking an embarrassing Mac failure at work.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-30741047578392150522014-08-17T13:49:00.003-07:002014-08-18T12:30:29.786-07:00Python CodeEval boiler plateI've been doing some <a href="https://www.codeeval.com/">CodeEval</a> challenges. I've kept each in a small structured project. After a few, it was obvious that I needed to be able to run locally with my own test data and expected results, but be able to submit the source code unaltered.
I have a folder for each challenge that contains three files. The source .py file, a small shell script and a file containing test data.
This is what the boiler plate looks like ('balanced smileys' is the name of one of the challenges):
<pre class="brush:python;">
import sys
def balanced_smileys(message):
"""
your code goes here, returning the result
"""
def code_eval(challenge):
with open(sys.argv[1],'r') as filehandle:
for line in filehandle:
candidate_and_expected_result = [value.strip() for value in line.strip().split('| expected result =')]
candidate = candidate_and_expected_result[0]
expected_result = candidate_and_expected_result[1] if len(candidate_and_expected_result)>1 else None
try:
result = challenge(candidate)
print(result)
if expected_result:
assert str(result) == expected_result,'%s : Expected:%s, Got:%s'%(candidate,expected_result, result)
except IndexError:
pass
code_eval(balanced_smileys)
</pre>
The test data file (balanced_smileys.txt) looks like this:
<pre class="brush:text;">
:(:):)(::)(:() | expected result = YES
:(( | expected result = NO
i am sick today (:() | expected result = YES
(:) | expected result = YES
hacker cup: started :):) | expected result = YES
)( | expected result = NO
</pre>
The launch script is simply this:
<pre class="brush:shell;">
python balanced_smileys.py balanced_smileys.txt
</pre>
When I make changes, I simply run:
<pre class="brush:shell;">
sh balances_smileys.sh
</pre>
This works well for most challenges and saves a bit of mucking about.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-20603001111413502972014-07-15T02:19:00.000-07:002014-07-15T02:19:57.931-07:00PEP 20 > PEP 8While trying to become a better Pythoneer, I'm struggling a little with PEP 8. I'm isolated, so I kind of don't care, but at some point I may have to learn to play well with others, so I should.
I got a reminder of PEP 8 during a brief attempt to use PyCharm. I've only very briefly used an IDE with any success. That was with Eclipse and Java. That was only with help from people and online tutorials. PyCharm pointed out the myriad ways I was breaking PEP 8. It didn't tell me the ways I was conforming to PEP 20.
Some code from PEP 8:
<pre class="brush: python;">
class Rectangle(Blob):
def __init__(self, width, height,
color='black', emphasis=None, highlight=0):
if (width == 0 and height == 0 and
color == 'red' and emphasis == 'strong' or
highlight > 100):
raise ValueError("sorry, you lose")
if width == 0 and height == 0 and (color == 'red' or
emphasis is None):
raise ValueError("I don't think so -- values are %s, %s" %
(width, height))
Blob.__init__(self, width, height,
color, emphasis, highlight)
</pre>
And this is how I'd probably write it:
<pre class="brush: python;">
class Rectangle(Blob):
def __init__(self,
width,
height,
color = 'black',
emphasis = None,
highlight = 0):
if 0 == width == height \
and color == 'red' \
and emphasis == 'strong' \
or highlight > 100:
raise ValueError("sorry, you lose")
if 0 == width == height \
and (color == 'red' or emphasis is None):
raise ValueError("I don't think so -- values are %s, %s" %
(width, height))
Blob.__init__(self = self,
width = width,
height = height,
color = color,
emphasis = emphasis,
highlight = highlight)
</pre>
From PEP 20, my intention is to hit the following:
<blockquote>Beautiful is better than ugly.
Explicit is better than implicit.
Readability counts.</blockquote>
And from PEP 8, I'm playing the trump card:
<blockquote>When in doubt, use your best judgment.</blockquote>
Some preferences, like extra spaces here and there, are obviously subjective. Objectively, my experience of writing and maintaining code in Ada and Pascal tells me to always be explicit about using named actual parameters. It's probably even more important in a dynamically typed language. If Python didn't allow me to do this, I'd likely have rejected the language. That is has this feature in common with Ada and the indented scope of Occam (No braces, Yay!) made it a no-brainer for me.
The main problem would appear to be that it's longer. Less code fits on-screen at once. I've never found that to be a problem even when I was editing in <b><i>eve</i></b> on VMS from a VT220.
This wouldn't bother me much, even though I think it's less readable:
<pre class="brush: python;">
Blob.__init__(self=self,
width=width,
height=height,
color=color,
emphasis=emphasis,
highlight=highlight)
</pre>
But this drives me insane:
<pre class="brush: python;">
Blob.__init__(self,
height,
width,
color,
emphasis,
highlight)
</pre>
If you don't understand why, the deliberate mistake should be enough to persuade you that in the majority of cases, you really want to be be explicit about those parameter names. I'd only an the exception for functions that only take one parameter.
Look, this is still fine even though the order deviated from the formal parameter list:
<pre class="brush: python;">
Blob.__init__(self = self,
height = height,
width = width,
color = color,
emphasis = emphasis,
highlight = highlight)
</pre>
And this is impossible to do sober unless it's deliberate. It's also easy to spot in a review or when debugging:
<pre class="brush: python;">
Blob.__init__(self = self,
width = height,
height = width,
color = color,
emphasis = emphasis,
highlight = highlight)
</pre>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-22605115135772957332014-07-09T08:56:00.000-07:002014-07-09T08:56:21.663-07:00Idiotic PythonOne of the problems of learning a programming language is that sometimes things one has written even relatively recently look idiotic.<br />
<div>
<br /></div>
<div>
Sometimes this is due to some bad advice on teh internets. Or perhaps misunderstanding an explanation.</div>
<div>
<br /></div>
<div>
I'd consider that I'm getting reasonably proficient in Python these days. I've had no formal teaching though, and I'm working in isolation, so I don't get feedback from colleagues or a mentor. I'm a lurker at the edge of the Python community.</div>
<div>
<br /></div>
<div>
I'm trying to improve. I bought <a href="https://www.jeffknupp.com/writing-idiomatic-python-ebook/">Writing Idiomatic Python</a> by <a href="http://www.jeffknupp.com/">Jeff Knupp</a>. I read through it, skimming for things both do already and don't do/never knew about. Things I already do were pat-on-the-back affirming, and I think confirmed I'm essentially on the right track. The rest is a learning opportunity.</div>
<div>
<br /></div>
<div>
When there's a lull at work, which isn't often, I open the book, and pick something to check against in my current project. Yesterday I looked at <span style="font-family: Helvetica Neue, Arial, Helvetica, sans-serif;"><b>Avoid comparing directly to True, False, or None </b></span>and started searching for <span style="font-family: Verdana, sans-serif;"><span style="color: blue;"><b>==True</b></span>; </span><span style="color: blue; font-family: Verdana, sans-serif;"><b>==False</b></span><span style="font-family: Verdana, sans-serif;">; </span><span style="color: blue; font-family: Verdana, sans-serif;"><b>==None</b></span><span style="font-family: Verdana, sans-serif;">; !</span><span style="color: blue; font-family: Verdana, sans-serif;"><b>=True</b></span><span style="font-family: Verdana, sans-serif;">; !</span><span style="color: blue; font-family: Verdana, sans-serif;"><b>=False</b></span><span style="font-family: Verdana, sans-serif;">; !</span><span style="color: blue; font-family: Verdana, sans-serif;"><b>=None</b></span><span style="font-family: Verdana, sans-serif;">; </span>thinking there'd be a few to fix. I found far more than I though would be there. Most disappointingly, quite a few <span style="font-family: Verdana, sans-serif;">!</span><span style="color: blue; font-family: Verdana, sans-serif;"><b>=False </b></span>and <span style="color: blue; font-family: Verdana, sans-serif;"><b>==True</b></span>.</div>
<div>
<br /></div>
<div>
I fixed a lot of this. Sometimes it seems less readable, so not in all places yet.</div>
<div>
<br /></div>
<div>
A significant penny dropped though, even though I've read this section a few times and nodded to myself as though I understood. It's the use of <span style="color: blue; font-family: Verdana, sans-serif;"><b>is not None </b></span>to check whether optional parameters have been set. Sadly, my code is riddled with well meaning but potentially harmful attempts to check optional parameters.</div>
<div>
<br /></div>
<div>
Another penny is teetering on the edge. In trying to go from harmful to idiomatic, I've made a significant number of minor changes. Some of these alter the order of an if statement to remove negation from the condition:</div>
<pre class="brush: python;">
if not weekend:
work()
else:
relax()
</pre>
<pre class="brush: python;">
if weekend:
relax()
else:
work()
</pre>
<div>
<br />
None of the changes are difficult, but there's risk of human error here which will be very difficult to find without adequate unit tests. I don't have unit tests. I've certainly tested as I've developed, but those tests were transient, not part of a test suite.</div>
<div>
<br /></div>
<div>
In a quick search on Python unit testing, I stumbled across a nice little <a href="http://www.jeffknupp.com/blog/2013/12/09/improve-your-python-understanding-unit-testing/">intro</a> from Jeff Knupp (again).<br />
<br />
Sigh. I fear that retro-fitting unit tests is going to expose some unpleasant coupling.<br />
<br />
<br /></div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-18530105536338535962014-07-05T07:57:00.000-07:002014-07-05T07:57:40.265-07:00Football is the World GameI'm not an Association Football fan. I much prefer Rugby football.<div>
<br /></div>
<div>
I used to play for fun/exercise in my 20s. Not to any standard, but enough to be able to appreciate the game a little. I watch Match of The Day sometimes, and usually get sucked in to The World Cup, because the standard is usually pretty high.</div>
<div>
<br /></div>
<div>
In the Internet age, this means that every four years, I get exposed to Americans belittling soccer.</div>
<div>
<br /></div>
<div>
http://daringfireball.net/thetalkshow/2014/06/16/ep-085</div>
<div>
<br /></div>
<div>
The real reason for this is indoctrination in a sport other than football. It's simply cultural bias. It's why I prefer Rugby, why Texans prefer Gridiron, why Canadians prefer Hockey, or the Swiss prefer Tennis.</div>
<div>
<br /></div>
<div>
It's important to understand that football is the world game. I suspect it's popular for two reasons. The rules are really pretty simple, so it can be grasped easily. The only equipment needed is a field, or a street or a car park; a football, volleyball, tennis ball, tin can, or even a stone. And, of course, jumpers for goalposts. It's a game all almost all children, all over the world can play for free. In unsupervised children's games, the only vaguely complex rule, offside, is discarded in favour of simply ridiculing goal-hangers. Offside is enforced by peer pressure.</div>
<div>
<br /></div>
<div>
A common theme in disparaging football is that the one thing that separates us from animals is our hands, and hands aren't allowed. I find this puzzling. The main thing that separates us from animals is our brains. Other animals have hands, can use tools, are bipedal etc. None can understand and play football.</div>
<div>
<br /></div>
<div>
I'd add something about baseball fielders needing catchers' mitts, which seems laughable to someone who's played cricket, but that would just be wallowing in the ignorance of my own cultural bias.</div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-86187959071290114752014-07-05T06:58:00.007-07:002014-07-05T06:58:59.115-07:00I switched from Markdown Pro to MacdownThe main reason: Unlike <a href="http://www.markdownpro.com/">MarkDown Pro</a>, syntax highlighting is built in to <a href="http://macdown.uranusjr.com/">MacDown</a> .<br />
<br />
<a href="http://macdown.uranusjr.com/">MacDown</a> is also free, although I'm perfectly happy to pay for good software I find useful.<br />
<br />
The markup for code in MacDown is very simple:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-IKhGvA_0DnZltU-aIDTVoR8QT7DlG3cnO7N7Zw9O5iPKIQgYXPgCdGa_EYUp9Lo40G7KaKi4ty1IHkjREnIk5zv9m4NnSAEH8yml-v9rYR3MM3R9d3HRoYFSWEO3YItXusBZJVnBO4E/s1600/schedule_md.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-IKhGvA_0DnZltU-aIDTVoR8QT7DlG3cnO7N7Zw9O5iPKIQgYXPgCdGa_EYUp9Lo40G7KaKi4ty1IHkjREnIk5zv9m4NnSAEH8yml-v9rYR3MM3R9d3HRoYFSWEO3YItXusBZJVnBO4E/s1600/schedule_md.jpg" height="124" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
This is a lazy stop-gap. I ought to be generating documentation from embedded docstrings automatically …but that's for another day.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-75349179840482554192014-05-01T17:26:00.000-07:002014-05-01T17:26:57.327-07:00Dynamically adding instance methods.I've been playing with some code today. It works, but may well be too clever for its own good. It may be slightly insane. There may be much better ways to do this.
I'd written a little class (SingleCommandSFTP) to make some other code a little shorter and neater. With one command, it was no problem, but when it expanded to three, the duplication of calls to __open and __close irked a little, so I added __run_command. The pragmatic thing to do was to stop. But unfortunately, I was having fun, and wondered about dynamically adding instance methods to call __run_command for all the available commands.
I ended up with this:
<pre class="brush: python;">
class SingleCommandSFTP(object):
"""
SingleCommandSFTP is a simple abstraction of the the Paramiko
SFTP client.
http://www.lag.net/paramiko/docs/paramiko.SFTPClient-class.html
e.g.
sftp_client = SingleCommandSFTP(host = "hostname",
username = "username",
password = "password")
sftp_client.remove(path = '/mnt/a/b/file.txt')
It is intended mainly for single operations as the
connection is opened and closed for each command.
For multiple commands it will be inefficient.
"""
def __init__(self,
host,
username,
password,
port = 22):
self.host = host
self.username = username
self.password = password
self.port = port
def __open(self):
self.transport = paramiko.Transport((self.host,
self.port))
self.transport.connect(username = self.username,
password = self.password)
self.sftp_client = paramiko.SFTPClient.from_transport(self.transport)
def __close(self):
self.sftp_client.close()
self.transport.close()
def __run_command(self,
command,
**params):
"""
Call to a paramiko.SFTPClient.'command' instance method.
"""
log.info('sftp_client.{command}({parameters})'.format(command = command,
parameters = params))
self.__open()
method = getattr(self.sftp_client,command)
method(**params)
self.__close()
# instance methods using __run_command for all instance methods of SFTPClient
# are added once, dynamically, below.
# SFTPClient Reference can be found at http://www.lag.net/paramiko/docs/paramiko.SFTPClient-class.html
def instance_method_code_string(object,attr):
argspec = inspect.getargspec(getattr(object,attr))
parameters = [arg for arg in argspec.args]
if argspec.defaults:
for index in range(len(argspec.defaults)):
try:
parameters[-1-index]+='="' + argspec.defaults[-1-index] + '"'
except:
parameters[-1-index]+='=%s' %argspec.defaults[-1-index]
if argspec.varargs:
parameters.append['*'+argspec.varargs]
if argspec.keywords:
parameters.append['*'+argspec.keywords]
code_string = "def {name}({parameters}):\n".format(name = attr,
parameters = ','.join(parameters))
code_string +=" self._SingleCommandSFTP__run_command(command='{name}',{parameters}"\
.format(name = attr,
parameters = ','.join('{p}={p}'.format(p=p) for p in argspec.args[1:]))
if argspec.varargs:
code_string +='*'+argspec.varargs
if argspec.keywords:
code_string +='**'+argspec.keywords
code_string +=")\n"
return code_string
def add_SFTPClient_equivalent_instance_methods_to_SingleCommandSFTP():
instance_method_names = [attr for attr in dir(paramiko.SFTPClient) if getattr(paramiko.SFTPClient,attr).__class__==paramiko.SFTPClient.__init__.__class__ and attr[0]!='_']
for instance_method_name in instance_method_names:
code_string = instance_method_code_string(object=paramiko.SFTPClient, attr=instance_method_name)
exec(code_string)
setattr(SingleCommandSFTP,instance_method_name, eval(instance_method_name))
if 'instance_methods_added' not in dir():
instance_methods_added = True
add_SFTPClient_equivalent_instance_methods_to_SingleCommandSFTP()
</pre>
getattr, setattr, eval, exec, getargspec. I won't have bloody clue what this does in two weeks' time!bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-66526622682446022462014-04-05T01:56:00.001-07:002014-04-05T01:56:06.641-07:00#RedirectToAppStoreAdsSuck<span style="-webkit-text-size-adjust: auto; background-color: rgba(255, 255, 255, 0);">#RedirectToAppStoreAdsSuck</span><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></span></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">I'm getting a bit fed up with ads in my browser redirecting me to the App Store. So I decided to install the apps (if they are free), immediately remove them, and leave a negative review.</span></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></span></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">I suggest we all do this if we have a spare minute. The danger is that the apps climb the charts, but I found the process to be cathartic.</span></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></span></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">Feel free to cut and paste the text below into the review.</span></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></span></div><div><br></div><div><span style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">"I Installed and immediately deleted this app without opening it in order to leave this negative review to complain about being redirected to the App Store from an ad in a web page.</span><div style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></div><div style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">Seriously, this is an intensely intrusive, terrible way to try to get me to try your app.</div><div style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></div><div style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">Please stop!</div><div style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;"><br></div><div style="font-family: '.HelveticaNeueInterface-Regular'; font-size: 23px;">#RedirectToAppStoreAdsSuck"</div></div>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-18760902624617929592013-12-19T04:29:00.001-08:002013-12-19T04:35:28.753-08:00Markdown Pro and Syntax HighlightingI've been writing some documentation for some code in markdown using <a href="http://www.markdownpro.com/">Markdown Pro</a>, but the code looked a little boring:<br />
<br />
<pre>def func(blah):
pass
</pre>
<br />
I've used Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">Syntax Highlighter</a> on Blogger, so I figured I could use it for these pages too.
<br />
<br />
<pre class="brush: python;">def func(blah):
pass
</pre>
<br />
This worked quite well, and I wrote a script (thinking that I was being clever) to add the syntax highlighter code to all the HTML files in a folder hierarchy. The only problem was that the syntax highlighting code isn't shown in the Markdown HTML view, XML inside pre tags was blank.
<br />
<br />
A couple of days ago, I started tweaking the Markdown Pro generated css to make the tables a bit nicer and colours of headings stand out a little more. Last night, as I was dropping off to sleep, it occurred to me that I may be able to add the highlighter css and javascript to a Markdown Pro template too. Just tried it, and it works. The template has to be re-applied to refresh after changes in order to force the javascript to run. Export to HTML is still good. It's necessary to refresh in order to save the highlighted code to PDF.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh2TPmHpig2rCmulOHWBtgY0C-RyNfdXZzbn7nnCiWgWkJcKWtm9n1i21vsoccWMW2wHVDctPVrQYYrcjw7YmoWDYPE9RbtCXkW3yHEnINGDncM22wtMOfjYt0oXYSy2kw5gzG2T9Be_8/s1600/double_click_scripts_md_and_Blogger__def_dayCoder_self___-_Create_post_and_App_Store.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="322" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh2TPmHpig2rCmulOHWBtgY0C-RyNfdXZzbn7nnCiWgWkJcKWtm9n1i21vsoccWMW2wHVDctPVrQYYrcjw7YmoWDYPE9RbtCXkW3yHEnINGDncM22wtMOfjYt0oXYSy2kw5gzG2T9Be_8/s640/double_click_scripts_md_and_Blogger__def_dayCoder_self___-_Create_post_and_App_Store.jpg" width="640" /></a></div>
<br />
Note that the 'template' isn't the usual simple template, but all of the exported css that Markdown Pro would generate on exporting to HTML, (with <script> tags).
<br />
<br />
<a href="https://dl.dropboxusercontent.com/u/1438118/mardown_pro_tweaked.css">(The 'template' file is here if you're curious)</a>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com1tag:blogger.com,1999:blog-8148933216702728291.post-63101061327186729522013-12-09T06:37:00.000-08:002013-12-09T06:40:41.583-08:00SFTP Python Paramiko (and some of the problems I had)I needed to rename a file on a RHEL server as part of some test automation scripts. Hope this helps.<br />
<div>
<br /></div>
<div>
I used <a href="https://github.com/paramiko/paramiko">paramiko</a> to do it with SFTP. I pretty much copied <a href="http://stackoverflow.com/questions/3635131/paramikos-sshclient-with-sftp">some code from Stack Exchange</a> to make this:<br />
<br /></div>
<pre class="brush: python;">import paramiko
class SingleCommandSFTP(object):
def __init__(self,
host,
username,
password,
port = 22):
self.host = host
self.username = username
self.password = password
self.port = port
def _open(self):
self.transport = paramiko.Transport((self.host,
self.port))
self.transport.connect(username = self.username,
password = self.password)
self.sftp_client = paramiko.SFTPClient.from_transport(self.transport)
def _close(self):
self.sftp_client.close()
self.transport.close()
def rename(self,
source,
destination):
self._open()
self.sftp_client.rename(oldpath = source,
newpath = destination)
self._close()
# Add further commands as and when required.</pre>
<br />
It only has rename, but that's all I need for now. It would probably be worth making a decorator for the _open / _close functions if many more functions were to be added, but I don't quite know how to do that (yet).<br />
<br />
<h2>
Problems (Mac):</h2>
If you try to easy_install paramiko on Mavericks, it'll probably fail because it can't compile pycrypto. You need to install <a href="https://itunes.apple.com/gb/app/xcode/id497799835?mt=12">Xcode</a> and fiddle about a bit (Found at <a href="http://stackoverflow.com/questions/8102292/problems-installing-pycrypto-on-osx">Stack Exchange</a> and <a href="http://blog.abakas.com/2012/02/pycrypto-on-os-x-lion.html">Abakas</a>):<br />
<ul>
<li><span style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px;">In Xcode, go Preferences > Downloads, and click on the "Install" button next to "Command Line Tools" to install the compiler needed by Python.</span></li>
<li><span style="background-color: white; font-family: Arial, 'Liberation Sans', 'DejaVu Sans', sans-serif; font-size: 14px; line-height: 18px;"><span style="font-family: Times; font-size: small; line-height: normal;">sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2</span></span></li>
</ul>
I also got this at some point: <span style="background-color: #eeeeee; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; font-size: 14px; line-height: 18px;">warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.</span> Unfortunately I can't remember what I did to fix that.<br />
<br />
<br />
<h2>
Problems (Windows):</h2>
On Windows, it wasn't practical to install a suitable compiler to build pycrypto from source. I used the 32-bit installer for Python 2.7 (<a href="http://www.voidspace.org.uk/python/modules.shtml#pycrypto">downloads are here</a>). I had installed Python for all users, but that caused another problem solved by <a href="http://stackoverflow.com/questions/3008509/python-version-2-6-required-which-was-not-found-in-the-registry">Stack Exchange</a>. I uninstalled Python an installed for the user only.<br />
<br />
I also had to install the <span style="background-color: white; font-family: Arial, Verdana, Geneva, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 15px; font-style: italic; line-height: 21px;"><a href="https://pypi.python.org/pypi/ecdsa/">ECDSA cryptographic signature library</a></span><span style="background-color: white; font-family: Arial, Verdana, Geneva, 'Bitstream Vera Sans', Helvetica, sans-serif; font-size: 15px; font-style: italic; line-height: 21px;"> </span>as this wasn't found when importing <a href="https://github.com/paramiko/paramiko">paramiko</a>.<br />
<br />bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-50718500035462080342013-10-29T13:19:00.002-07:002013-10-30T04:15:14.965-07:00Mavericks "Mail Web Content" going to 100% CPUIf your fans are a blowin', check Activity Monitor/CPU (sorted by descending % CPU). You may see 'Mail Web Content' at the top, hogging 100%. I've also seen two instances hogging 100% each.<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSjgV5ZcbttCExCkmvCdEXql8bijGoR63SfD56x-GuXle7CZYbquPBLbQj3DlcZHkMKHTXySF31LhxYaeACarFrJZnJuohavK-NZr4Y1d_SzSl-R7JtH9rK6EaMwINbknkVUNwFQ3g8Yg/s1600/Activity_Monitor__All_Processes_.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="51" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSjgV5ZcbttCExCkmvCdEXql8bijGoR63SfD56x-GuXle7CZYbquPBLbQj3DlcZHkMKHTXySF31LhxYaeACarFrJZnJuohavK-NZr4Y1d_SzSl-R7JtH9rK6EaMwINbknkVUNwFQ3g8Yg/s320/Activity_Monitor__All_Processes_.jpg" width="320" /></a></div>
<br /></div>
<div>
Bouncing Mail doesn't always do the trick. I've had some success with just killing the process, but YMMV.</div>
<div>
<br /></div>
<div>
I couldn't find any info on it from a quick Google.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFnW13yaNZ-jjNs7pvqpjf_pCC5oZbeLFZUenp3iUGoBA7S4mQEVTn1oXMjgbsh8w7UYCC4AtbfbugAfGAedBa1p50J-lSyK2JQHnog1APjHtHylNg6I28oh0-FYyTbxD9M4Wgz30Y08I/s1600/MenuTitle-2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="177" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFnW13yaNZ-jjNs7pvqpjf_pCC5oZbeLFZUenp3iUGoBA7S4mQEVTn1oXMjgbsh8w7UYCC4AtbfbugAfGAedBa1p50J-lSyK2JQHnog1APjHtHylNg6I28oh0-FYyTbxD9M4Wgz30Y08I/s320/MenuTitle-2.jpg" width="320" /></a></div>
<br /></div>
<div>
<br /></div>
<div>
My hypothesis is that it's HTML Mail rendering that's got it's knickers in a twist. When the process had been quit, the mesage I was reading was blank, but selecting another one and then coming back to the blank one ... it was rendered, and it was and HTML page.</div>
<div>
<br /></div>
<div>
Dunno if that helps anyone. Maybe it's enough to know you're not alone ?</div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com1tag:blogger.com,1999:blog-8148933216702728291.post-22620898061593973242013-05-25T05:10:00.001-07:002013-05-25T05:10:29.236-07:00Is a blog subject a headline?See what I did there?<div><br></div><div><span style="font-family: 'Helvetica Neue'; font-size: 16px; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); ">http://daycoder.blogspot.com/2013/05/is-new-analogy.html</span></div><div><span style="font-family: 'Helvetica Neue'; font-size: 16px; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); "><br></span></div>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-14584551802758772013-05-25T05:05:00.001-07:002013-05-25T05:09:24.656-07:00Is 'Beans' the new 'Cars' analogy?<a href="http://www.technovia.co.uk/2013/05/cheap-tablets-and-baked-beans.html">http://www.technovia.co.uk/2013/05/cheap-tablets-and-baked-beans.html</a><div><br></div><div>See what I did there?</div>bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-62078693070733461902013-04-15T10:16:00.002-07:002013-04-15T10:16:24.872-07:001993 versus 2013<div class="separator" style="clear: both; text-align: left;">
The 1993 watch function <b>has</b> been replaced in the 2013 version.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.imgur.com/nuUGHaY.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://i.imgur.com/nuUGHaY.jpg" width="320" /></a></div>
<br />
I don't know who made this, so unfortunately, I'm unable to add a credit.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com1tag:blogger.com,1999:blog-8148933216702728291.post-64993466105135863022013-04-13T11:28:00.001-07:002013-04-13T11:28:41.505-07:00Panic's Status BoardPanic's <a href="http://panic.com/statusboard/">Status Board</a> is fascinating. It's using an iPad for content design/layout, although HTML components could, I guess be designed anywhere and imported later. Data, I suppose can come from any networked source, and output can be via HDMI or Airplay if an Apple TV is used.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKH6uTGA1staZ7vnHsc3vcStLvZ7tbPgCP2UCEaQi7Da_8MLixjV3Irabf7QRw9Dg0LTct6n_70efj-jwXTZg2ZS740bOBDhjswVP7VLyiB9lx9VjEtG02thvo3KjIbspu6LMRw7hyphenhyphenjHE/s1600/Screenshot_13_04_2013_19_27.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKH6uTGA1staZ7vnHsc3vcStLvZ7tbPgCP2UCEaQi7Da_8MLixjV3Irabf7QRw9Dg0LTct6n_70efj-jwXTZg2ZS740bOBDhjswVP7VLyiB9lx9VjEtG02thvo3KjIbspu6LMRw7hyphenhyphenjHE/s320/Screenshot_13_04_2013_19_27.jpg" width="204" /></a></div>
<br />
What's odd here is that when it's outputting to an HDTV via Airplay, an Apple TV is required. The Apple TV is perfectly capable of being the client device. What I think should be happening is that the Status Board is prototyped on the iPad (or Mac), and the configuration uploaded to a Status Board app on the Apple TV, which happily runs it all day long. That's a beautiful bit of digital signage for £9.99 + £99 + £Display.<br />
<br />
There are often vague murmurs about Apple allowing apps for the Apple TV, it's this kind of thing from Panic that makes me want to see it happen.bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-46690253461973502412013-03-19T11:53:00.000-07:002013-03-19T11:53:16.815-07:00Pervert!I watched <a href="http://www.imdb.com/title/tt0460898/?ref_=fn_al_tt_2">a terrible movie</a> on Netflix last night. It's meant to be bad though, so has a certain charm. Badly written, mostly badly acted, poor production values, laughable special effects, juvenilia, moderate but nevertheless gratuitous nudity, misogyny, misandry, homophobia, etc.<div>
<br /></div>
<div>
I short, a genuine, not up its own arse B movie. Think <a href="http://www.imdb.com/title/tt0084090/?ref_=fn_al_tt_1">Inseminoid</a> rather than <a href="http://www.imdb.com/title/tt0114898/?ref_=fn_al_tt_1">Waterworld</a>.</div>
<div>
<br /></div>
<div>
I'd recommend not watching it unless you're willing to embrace its deliberate awfulness. The first frame should probably put you off...</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvH9FQKf1pSwWqaYnx_Kvezprahx8PbUSkHm7UADR-neGuNazcFYWxEg6VA55uDmj6sOrDd_BBAi5T0j3cwyrqhWy6U3Y72WqS5GvZr_S55uiM4NNUK-VccfHc8cEXDR6N2nBjH-LLMFI/s1600/Photo+18-03-2013+23+10+23+(HDR).jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="190" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvH9FQKf1pSwWqaYnx_Kvezprahx8PbUSkHm7UADR-neGuNazcFYWxEg6VA55uDmj6sOrDd_BBAi5T0j3cwyrqhWy6U3Y72WqS5GvZr_S55uiM4NNUK-VccfHc8cEXDR6N2nBjH-LLMFI/s320/Photo+18-03-2013+23+10+23+(HDR).jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<a href="http://www.imdb.com/name/nm0761343/?ref_=tt_cl_t3">Darrell Sandeen</a> actually put in as credible a performance as was possible. <a href="http://www.imdb.com/name/nm1707342/?ref_=tt_cl_t4">Juliette Clark</a> also looked as though she might be able to act, though there wasn't much call here. The rest of the cast's acting was atrocious.</div>
<div>
<br /></div>
<div>
Having described most of the plot to a colleague, Bobby, over lunch today, another, John, who I'd venture is more of a movie buff, sat with us…</div>
<div>
<br /></div>
<div>
Me: "I've been telling Bobby about terrible film I watched last night".</div>
<div>
John: "What was it?"</div>
<div>
Me: "Pervert! In essence, a homage to Russ Meyer"</div>
<div>
John: "Fantastic large breasted women in the desert?"</div>
<div>
Bobby:"That's exactly what he said!", amazed that John worked this out from the exchange.</div>
<div>
<br /></div>
<div>
I think it was worth watching it just for that bit of conversation. For the stop-motion, voodoo-cursed, detached, sentient, penis monster, not so much.</div>
<div>
<br /></div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-26189358128130324022013-03-16T16:47:00.000-07:002013-03-16T16:48:16.373-07:006 Nations ChampionsGreat day. Wales v England, Cardiff, last day of the 6 Nations.<br />
<br />
England 4 for 4. Wales 3 for 4.<br />
<br />
If England win, they get the Grand Slam, Championship, Triple Crown.<br />
<br />
If Wales win, but the margin is less than 7, England win the Championship.<br />
<br />
If Wales, the margin is 7, and England score 3 more tries than Wales, England win the Championship.<br />
<br />
If Wales win by 7, and England score 2 more tries than Wales, the Championship is shared.<br />
<br />
If Wales win by 7, and England score fewer than 2 more tries than Wales, Wales win the Championship.<br />
<br />
If Wales win and the margin is more than 7, Wales <b>win and retain</b> the Championship.<br />
<br />
Before the game, it seemed to close to call. This is an England that beat the All Blacks, but were lucky to scrape it against Italy. Wales have been getting steadily better with each game, but had a shocker of a first half against Ireland.<br />
<br />
I've been quietly excited all week. I was hoping for a win, obviously, but didn't dream of what transpired. Wales won, no, destroyed them with a record 30-3 score (They've done us by more in the past, mind you). Watching the BBC News (in England) after the game, I couldn't resist rewinding, making a shaky recording directly form the TV screen using my phone and making this…<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/LK1huj6xL1k?feature=player_embedded' frameborder='0'></iframe></div>
<br />bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0tag:blogger.com,1999:blog-8148933216702728291.post-82316069760882173932013-03-16T15:58:00.000-07:002013-03-16T15:58:13.111-07:00Marketing BullshitI'm not a fan of marketing bullshit. I'm a bit of an Apple fan. It only seems fair that I call them out on some marketing bullshit on the new <a href="http://www.apple.com/iphone/why-iphone/">Why-iPhone</a> page.<br />
<br />
<br />
<blockquote class="tr_bq">
<img alt="Only iPhone has the Retina display." height="94" src="http://images.apple.com/iphone/why-iphone/images/retina_title.png" style="border: 0px; display: block; margin: 0px;" width="335" />The Retina display on iPhone ushered in the era of super-high-resolution displays. Its pixel density is so high, your eye can’t distinguish individual pixels. The images and words are amazingly vivid and crisp. Everything just looks so real. In fact, once you see a Retina display, you’re never satisfied with anything less. Yet it remains a feature found only on iPhone and other Apple products.</blockquote>
<br />
<br />
Really Apple? Isn't Retina just ppi measurement? And for a phone, roughly more than 300ppi? The Galaxy S3's display is 330ppi. This week's Galaxy IV's display is 440ppi. If these aren't Retina, then Retina is Apple marketing Bullshit.<br />
<br />
<br />
<blockquote class="tr_bq">
<img alt="Only iPhone has Siri. Your wish is its command." height="93" src="http://images.apple.com/iphone/why-iphone/images/siri_title.png" style="border: 0px; display: block; margin: 0px;" width="430" /></blockquote>
<blockquote class="tr_bq">
Siri, the intelligent assistant, lets you use your voice to send messages, schedule meetings, place calls, set reminders, and more. You can even ask Siri who’s winning the game. And with Eyes Free, you can use Siri to get things done in your car without taking your eyes off the road. You can speak naturally to Siri — it understands what you say, knows what you mean, and helps you do the things you do every day. All you have to do is ask.</blockquote>
<br />
<div style="background-color: white; color: #333333; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 14px; line-height: 22px; margin-bottom: 18px; padding: 0px; word-spacing: -1px;">
<span style="color: black; font-family: Times; font-size: small; line-height: normal; word-spacing: 0px;">Really Apple? Isn't Google's equivalent widely considered to be faster and more accurate? At this stage, Siri is just Apple's trademark for voice recognition. Marketing bullshit.</span></div>
bobhttp://www.blogger.com/profile/13622911847997246805noreply@blogger.com0