Wednesday, 27 January 2010

Developing using Eclipse CDT, remote Linux server and rsync


For quite a while I used to have a huge pain in my arse — namely, programming in C++ for Linux on my Mac.

I think I said this before, but I like IDEs — especially, I like Eclipse: it saves my time and allows me to develop stuff much faster and more efficiently, it is also great when you’re learning some new code (and if you have a very large project at hands, that means pretty much all the time).

The problem was, I should still build the project on Linux. That means I was doomed to put all the sources on the network drive, which was accessible both from my Mac and from Linux server, and build it all there. Not convenient and slow. Very slow, in fact — builds were taking ages and ages. Other guys were using stuff like vim and emacs, and I didn’t find it useful at all: these tools are old, and give you next to none help when it comes to writing the code. So I kept struggling with using Eclipse in this hostile environment, until I come out with the idea, which is best of all described by these few lines of Makefile:

rsync -rvz .
ssh 'cd /path/to/project && build'

test: build
ssh 'cd /path/to/project && make test'

Now, when I finish editing the files (or want to check something) I simply do on my local machine:

 kirillov:/local/source/dir $ make test 

And voila — all sources are synchronised, built and tested! An extra benefit of this approach is that I have no object files, .d files, executable files and other useless stuff in my dev-folder (and, consequently, visible in my project). An only downside is, if your source tree is very large, rsync can take a good deal of time (that is why I’m syncing only my subproject in my real Makefile).


Tuesday, 26 January 2010

SSH tunnelling, VNC and Mac OS X

That said, one can do almost anything as long as this anything is not writing a lecture (which that specific one should be doing — at least, theoretically).

Now, I'm not different in any sense. Instead of writing an Image-Based Information Processing lecture (which puts me to sleep almost immediately — or is it the professor who does it?) I've managed to get a VNC working on my Mac. On my home Mac. Well, it all started with the TeamViewer, which suddenly stopped to work. It was disappointing, as I couldn't play with Boxee on my home computer during the lecture anymore, so I've tried to invent something. Indeed, I could SSH into my iMac (via a resident NAS which acts as an SSH gateway to my home network). What I ended up doing could be best described by these commands:

imac$ sudo port install tightvnc
imac$ vncserver ... password ... verify ... your VNC server is running on iMac:1
nas$ sudo ssh -f roman@imac -L 5901:localhost:5901 -N
macbook$ ssh -f my-nas-username@my-nas-host 5901:127.0.01:5901 -N # it didn't work with localhost here

Then I simply used JollyFastVNC to VNC into my iMac by connecting to and port 5901. Yay! However, ten minutes later I realised, that in fact I can set up a tunnel to my Mac's default (bundled) VNC server on screen 0. So I did — and apart of the fact that I should've enabled monitor mirroring (otherwise it tried to skew my iMac's monitor + my HD TV connected to it into one rectangular window, which didn't look neither pretty nor comfortable), it did work quite good. That works and an only question I ask myself - why on Earth do I need it if TeamViewer has started working again?

Friday, 22 January 2010

Weird @1Password / Chrome / @Posterous bug

Download now or watch on posterous (3628 KB)

Whenever I try to use pre-pre-alpha of 1Password for Chrome to login in to my Posterous, I can see an extremely weird picture (try it on YouTube with resolution of up to 1080p if Posterous video is a bit off).

Chrome Dictionary — very useful extension, at least for me

OK, fine, I know — an average Englishman is fairly unlikely to need a dictionary when reading in his very own native English; an educated Englishman will hardly need dictionary ever. However, for us, foreigners, expats, or simply people who struggle (to whatever degree) to speak and read the language of Shakespeare, Jane Austen and Austin Powers, this may become handy. 

You see the word. You don't understand it. You double click it. Now you do [understand it and go ahead]. 

That's pretty much the whole usage pattern for a new Google Chrome extension — Google Dictionary, offered, surprisingly, by Google itself. Well, it's not your average dictionary, it looks just a bit more sleek and fun, explaining things in a language which is likely to be understand by someone who doesn't have a PhD in English literature; well, it works for me. Take a look yourself if you're like me — not feeling entirely confident in a grim and dangerous world of irregular verbs, past perfect tenses and their ilk; or again, may be you're just curious. Take a look anyway.

Custom Search Engines in Google Chrome

Did you know you can define custom search engines in Google Chrome? Yes you can. When I want to find a map of something, I type "map <mysomething>" in address/search bar and — voila, a map appears. How to do it? It's simple, really:
  1. Right-click your address bar
  2. Click "Edit Search Engines"
  3. Click "Plus" button 
  4. Type your search engine name
  5. Type an activator (a short keyword you should use to tell Chrome that you want to use a custom search)
  6. A search URL, with query replaced to "%s"
It's even more simple once you've seen the pictures. Try it for yourself — saves a lot of time.

Thursday, 21 January 2010

Sync on Save/Run in NetBeans

Suddenly found an absolutely killing feature of NetBeans 6.8 (don't
know, it could've been there before, but I found it only now) — it can
sync every file you save locally to remote server (FTP/SFTP), which
is, IMO, absolutely brilliant as now I can edit files locally using
nice IDE and then build and run them on large scary Linux server.
Probably, picture says it all.

Wednesday, 20 January 2010

About Apple's announcement on 27th

One guy: don't want to replace my MacBook Pro right now, need to wait until 27th
Me: is there anything to wait for?
One guy: it certainly is
Me: you know what is it?
One guy: Yep.
Me: fancy to share?!?!?!?!!11
One guy: NDA.
Me: ...
One guy under NDA: do I really want to get killed?

Monday, 18 January 2010

Looking for alpha-testers for a new Twitter App

Update: it is not working right now. Now read on, but I warned you.

Hey guys,

I've kind of handcrafted a Twitter app over the weekend. Shortly — it's a URL scrap book, which monitors your feed and collects all URLs, un-shortens them and stores for future use, so whenever you try to find that link you posted a week ago, you shouldn't be lurking over your Twitter feed (as Twitter Search is unlikely to help), you simply go to this app and find it there.

Now, it's early alpha. It's working. Search is sort of working. Multi-word search is broken and phrase search is broken too, probably, it will remain that way until the next release of Google's AppEngine. However, this app is already useful — at least I was able to find one of URLs I've been looking for for ages.

What it can do? It can import your feed. It can monitor it. It can even import as much as 3200 your previous status updates (only ones with URLs are stored).

And it's in progress. It will become more powerful, so much more powerful — it's difficult to imagine, how many useful information is stored in Twitter status updates. But for now it's only alpha — hence access is naturally restricted. If you're interested in testing it — please let me know and I will sign you up (for now this is an only way of doing so — that was done on purpose).

Few teasers just to keep your interest :-)



P.S. if you're good with design and would like to sharpen your skills — do let me know. I'm notoriously bad when it comes to making something look good, and probably nothing and no one can help me with it; however, you can help this app look better, so if you're interested — contact me by any means.

See and download the full gallery on posterous

P.P.S. For you, techno-geeks — it's made with Google AppEngine, Django, Twitter OAuth and REST API and uses semi-ready full-text search functionality of AppEngine (thus search is semi-broken). And yes, I intentionally made screenshots from localhost — so I don't spoil the secret location :-)

Sunday, 17 January 2010

A URL matching regex in Python — any problems?

Can anyone see any flaws in it for real-world URL?

>>> str = 'and now that was a URL'

>>> urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&#+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', str)

>>> urls


For me it looks like working but you never now...  Comments from @HD42 would be highly appreciated =)

Saturday, 16 January 2010

An ordinary day at Roman's home workplace

It was an ordinary Saturday morning, a bit rainy, a bit grey but otherwise quite normal. So, one by one, I turned on all my four laptops and iMac and proceeded to my usual morning routine... 

To say the truth, Vaio laptop isn't mine — a technically challenged college of my wife has asked me to choose, buy and set it up for her. Small laptop (netbook) is Natalie's. Rest of them are indeed mine. 

Friday, 15 January 2010

VNC: Linux in Mac

via tweetie

It would be cool to ... (mac-boy's dreams)

It would be cool to have a way to switch "natures" of your Mac OS X, not unlike the way I change Perspectives in Eclipse from PyDev to Java whenever I start hacking different project. Let me illustrate it on one simple example. When I'm at work I'd love to have my work resources connected and available in Finder. That includes, say, some network shares, VNC servers, and so on. And — I would like to have them just in Finder's "Places" menu. When I go to uni, I'd love to have my Birkbeck folder there — may be not only this folder, but some of it's subfolders too, so I shouldn't go to Dropbox/Birkbeck/IBIP/Lectures just to find my image-based information processing lectures, I would rather select IBIP shortcut in Finder and get straight to it. But there's a problem — I don't need my IBIP shortcut at work. More than that, it would probably distract me and this is the last thing I want. On the other hand, my work network shares would be more than pointless at uni, as they'd be not only useless but even inaccessible without a VPN (and why do I need a VPN at uni?).

So, you see, Mac is good and Mac is cool, but quite a few things could be improved. (however, maybe I should spend a little bit of my time and write a script to fix all this stuff for me? that would certainly work...)

flickrpy + 30 lines of code = poor man's Flickr Backup solution

It uses somewhat buggy but excellent flickrpy module by James Clarke — works well for me after some small adjustments:

def main():
flickr.API_KEY = constants.API_KEY
flickr.API_SECRET = constants.API_SECRET

u = flickr.User(id = '92002612@N00')
sets = u.getPhotosets()

for ps in sets:
name = ps.title
name = name.replace('"', "'").replace("/", "_")

folderName = "/Users/kirillov/Pictures/Flickr/%s" % name
if os.path.exists(folderName):
print("Path exists, skipping: %s" % folderName )

photos = ps.getPhotos()

i = 0
for i,p in enumerate(photos):
src = p.getSizes()[-1]['source']
photoname = p.getTitle().replace("/", "_")

fname = '/Users/kirillov/Pictures/Flickr/%s/%s-%d.jpg' % (name, photoname, i)
data = u2.urlopen(src).read()
open(fname, 'w').write(data)

print('%s => "/Users/kirillov/Pictures/Flickr/%s/%s-%d.jpg"' % (src,name, photoname, i))

Upd: fixed and updated version posted.

Wednesday, 13 January 2010

Emacs Fingers Monster

via tweetie

New iPhone adapter for headphones: here we go again

Do you remember a while ago I posted about replacing my broken Griffin SmartTalk? Well, they replaced it — indeed they did. And guess what? It got broken again. In the very same place — where the cable connects to the jack. Same symptoms. Same problem. Same product. I decided not to hassle their customer support, because the best they can do is to send me another one which will again break in a couple of months — repeat until the warranty expires. 

So I decided it's a time to fix the root cause of the problem. Virtually all cheap headphones (and adapters too) have this problem, so I decided to get the one from Shure (which was a recommended accessory for my Shure SE 210 headphones — which I'm extremely happy with). So, I got myself a Shure MPA-3C.

I think photos say enough, finally answering the question why it shouldn't break in a months or two. Very solidly looking thick cable, protected jack connection, not thin and elegant by any standards, but seriously built, sturdy and durable, or at least it looks this way.

Hope this will sort the problem out, but now my music experience is Shure all the way through (except my iPhone, but everybody knows Shure doesn't produce any decent iPhones).  

Well, may be they should?

Tuesday, 12 January 2010

iPhone 3G, push-only email and battery life.

Yesterday I realised, that I am way too tired of my new iPhone's battery dying at 11PM every day — and if on every day it was dying at 11PM which is somewhat acceptable, on a bad day it died at 9PM just when I was leaving university building, looking forward for 30 minutes on a train accompanied by my iPod, ebook, RSS news or what's not. Now, that annoyed me — annoyed me much, and I decided it's a time to do something with it.

Yesterday I took a look at my email accounts on iPhone. 4 of them: MobileMe, my university email, Gmail for public stuff and my very private email. I switched off three of them, and set up a forwarding to my Gmail account. Then I switched my Gmail to Exchange. And that was it.

Dear, that was a difference. Today was a fruitful day and I received about a 100 emails on combination of my email accounts. I used Internet quite a bit, I listened to few podcasts and music, posted a number of updates using Tweetie, read Stephen King's book for about an hour during my commute, breakfast and very late after-work lunch, and you know what? 

Now it's 18:23. Battery on my iPhone is still full. I'm not kidding. That what it shows: it's full. I don't have any battery-monitoring utilities as I hardly feel any need in them, but I see, that despite all my unintentional efforts, iPhone's battery is still healthy as hell. And it couldn't make me happier.

There're just to simple things you need to understand from whatever I've written above:
  1. The fewer email accounts your iPhone checks, the longer it's battery will last.
  2. Checking email only when you have new email rather than every N minutes saves your battery even further.
That is it, chaps — hope my experience will help someone to save some of iPhone juice just enough for his or her way back home.

Facebook: email interface

Apparently email replies to Facebook comments which I just spotted is a brand new feature of Facebook:

via tweetie

Monday, 11 January 2010

FingerMgmt — an amazing MacBook Unibody's multitouch demo app

Download now or watch on posterous (4974 KB)

As it's been proved empirically by many users (using this application) MacBook Unibody's touchpad is able to recognise touches of up to 11 fingers. Well I have only one question and don't you dare call me deviant: where is this 11th finger and who are the target audience of these laptops? :-) 

Grab blä.se/ and find out by yourself!

Author of this wonderful bit of software — one Johan Nordberg and when I'm telling you this guy has very little to no problems with his creative thinking, believe me, I am just jealous.

(via lericson)

Thursday, 7 January 2010

iPhone 3G — brand new, yet with an old warranty

Got my brand new shiny iPhone 3G today. Surprised? I'm not — apparently, this is the way Apple replaces batteries to some iPhones. That's too bad that they didn't give me a replacement 3Gs, but there're no idiots in there, and, perhaps, they have a stock of old phones (you cannot buy iPhone 3G 16GB anymore, only 8GB for 3G version), so it took a couple of days to get a replacement one. Otherwise, reverting my iPhone to Day 0 (even for £55) isn't such a bad deal at all.


via tweetie