Hacker Newsnew | past | comments | ask | show | jobs | submit | more phpnode's commentslogin

Upgrade the links with jQuery. Here's a simplified version of what I use:

    $("a").bind("mousedown", function(e) { 
        $(this).data("href", $(this).attr("href"));
        $(this).attr("href","http://example.com/redirect?url=" + $(this).attr("href"));
    });
    $("a").bind("mouseup",function(e) {
        var el = $(this);
        setTimeout(function() {
            el.attr("href", el.data("href"));
        },10);
    });

This works by switching the url when a user clicks a link to your redirect url, then switching it back a fraction of a second after they mouse up. This means that your redirect works even if the user right clicks and opens in a new window / tab and when a user hovers over a link, they still see the normal URL in the status bar.

On the /redirect url just log any data you need and send a 301 or 302 redirect. The destination site will see your original page as a referrer, not your redirect url.


It doesn't work for keyboard access in the sense that you don't insert the redirect, but at least the link still takes them to the right place.

Seems like the original link following the `url=` should be processed by encodeURIComponent or else any original urls with chars like ""&" will break.


Have a look at the about us page, Kaseem Dean aka Swizz Beatz is listed as CEO.

http://www.megaupload.com/?c=about


"The best way to predict the future is to invent it."

That's the last place I was expecting to find a quote from Alan Kay.


I find foundation great for rapid prototyping, I can build a mockup in foundation in a few minutes and then iteratively improve on the design until it becomes a real product, as the name implies it's really a foundation to build on, it doesn't give you everything but it gives you 90% of what you need in a way that isn't restrictive.

Bootstrap gives you a lot more than foundation does, but I find it very restrictive, it's hard to make a bootstrap site not look like bootstrap (if anyone can point me to some counter examples I'd be interested). This is unsurprising since bootstrap was designed by twitter for a consistent look across their internal tools.

So my verdict is, for internal tools / quick hacks, use bootstrap. For mockups and real products, use foundation.


nice and all, but what i really want from github is the ability to pull request from the command line. (i know it's scriptable, but I've not got round to it yet)


One of my coworkers recently put this together. It lets you issue pull requests from the command line. Check it out:

https://github.com/AndrewLorente/pullme


Like hubs' pull-request?

https://github.com/defunkt/hub


I have to second the hub suggestion.

I use it daily and it's a timesaver. The syntax for creating a pull request from a branch on a non-forked remote forces you to always pass the -h option, but beyond that it's amazingly simple.


Also, you can very easily associate a pull request with an issue. If you're using GitHub issues for feature planning it makes it very nice.


looks great, thanks for the suggestion



I too wish php had a widely supported compiler, but in reality it's not something that most projects require. The overhead of interpreting php is a lot lower than e.g. making a single db call. Also, in the most common usage scenarios, PHP processes only live for the time it takes to deal with each request, so how do you approach that if you're compiling your code? Keep spinning up new processes or rewrite your application code?

Regarding MVC frameworks, try Yii - http://www.yiiframework.com


I wouldn't dismiss PHP's speed problems that quickly. Opcode caches typically don't speed up the actual execution, just the loading and parsing. I use zend server (with zend optimizer) and I've got PHP code that is hard CPU bound, as optimized as it can be, and still takes minutes to run to process perhaps 2 megabytes of raw data. By contrast, the exact same feature implemented in Delphi runs in less than 2 seconds, even though the code is an order of magnitude less efficient.

PHP isn't just orders of magnitude slower than JIT-ed or native compiled languages, but it has no affordances for that fact. There's no standard way to run code in the background. Zend won't start working on one either, because they sell a jobs queue as part of their Zend Server product.

Frankly, a JIT-ed PHP is the only feature I need. I appreciate the syntactic sugar added in the last few revisions of PHP, but honestly, I'd trade every new feature since PHP 5.2 for a bit more speed. With stuff like closures and traits it seems like they're working on the easy stuff instead of the necessary (but hard) stuff.


These speed charts are why I would compile Php. http://naspinski.net/post/AspNet-vs-php--speed-comparison.as... It seems worth it too me.

Thanks for the Yii link.


those charts don't say whether APC is enabled, which leads me to suspect that it isn't. APC is an opcode cache that greatly enhances php performance, no one runs a high traffic website without using APC


eAccelerator and XCache also do the same(ish) thing. APC usually helps way more on subsequent requests. While APC /can/ help a lot, it's not the magic speed bullet that some make it out to be -- if your app is a bodged mess of Joomla and stuff that you got outside developers to write for you, it'll probably still run like garbage with APC enabled.

Getting a bit off topic here, but one of the biggest performance killers I've seen is PHP devs writing Really Awful SQL(tm). Even beyond stuff like failing to use PDO and prepared queries to avoid SQL injections, if you look around you'll find tons of just really abysmal SQL. Typical problem: someone is using an oper in SQL that forces MySQL to not use indices. This absolutely kills performance and you typically won't notice it as a developer unless you're pre-populating your database with a large "real-world" dataset and doing proper performance testing.


Did not know about APC...nice. Does APC just compile it after the first time and save it in memory? Can you use APC to create a packaged compiled file?


bytecode caches (like APC) store the bytecode on the fly in memory. you can't create somthing like a "binary" file.

edit: at least they're not intended to create "binaries". you can probably mess around with APC and make php look and behave like a compiled language. but you won't gain any notable speed improvements beyond the on the fly caching.

edit2: you can store php projects in a jar like file, caller phar. http://php.net/phar


Here's my guess at how it's done:

Redditor has facebook app installed on their smartphone (or just uses the website), sets status to "OMG wife is going into labour, at the hospital now". Facebook now knows roughly where redditor was at the specified time based on the ip, they can narrow this down further by looking at keywords in the status message and check it against a list of addresses in the local area and select the best match.

When the redditor comes to upload their photos days or weeks later, facebook just checks the photo timestamp against the user's location +/- X hours and makes a guess at where the photos were taken.


It's probably a combination of techniques to be honest. They do have some unprecedented access to contextually heavy data, as well as an unusually large base of free labor to supervise the learning...

My creepy moment came when It correctly pointed out the exact location of this photo:

http://www.flickr.com/photos/40127665@N03/4788700749/in/set-...

I was in the middle of Costa Rica. For fear of roaming charges my phone was not on, and I never made a status update. The photo was taken on a D40 at the time, so no location exif data, and frankly the the picture is kind of generic.

My best guess is it used the other photos in the album to gain contextual information. For example this photo was in the same album:

http://www.flickr.com/photos/40127665@N03/4789329722/in/set-...

this, to me, would be extremely easy to recognize.


Both photos are in a public folder on Flickr called "Costa Rica".


the facebook album was named "D40 Pics", but it would be curious if it is cross referencing photos with flikr.


Simply not making a status update isn't enough. You'd have to never visit a page with a Facebook like button from a computer which you'd used ever to log in to Facebook with.

I'm yet to be convinced that this feature requires actually analysing image content at all. GeoIP and time stamps alone can provide a huge amount of context before you even start on things like mobile clients providing location data.


Or that species of insect only lives in Costa Rica.

Kidding! If it was that good, I really would be shocked.


The logic doesn't hold up. I uploaded a bunch of photos taken in Christchurch, New Zealand. The pics were over two years old and I now live in the UK and uploaded them from here. The photos were also taken on a cheap, point & shoot camera, not a smartphone.


It doesn't need to be taken on a smartphone. It's sufficient to open facebook on a smartphone only once (app or web) in roughly the same timeframe that the picture was taken. It can then look where one has been in the timeframe when the picture was taken by comparing the picture timestamp with the list of checkin ip addresses, and do a geolookup of the ip address against a location database.


Again, that doesn't align with my experience. The first smartphone I owned was when I arrived in the UK. In NZ, I was restricted to an old Nokia work phone.


Maybe you accessed facebook in a browser while in NZ? On a regular computer?


Guess: your friends also took pictures of the same events from similar angles and uploaded them, fb worked out their location from one of the other suggested methods, and then matched it to your photos through simple computer vision algorithms.

Or, you used facebook at some point while in that city, facebook recognised that your photo was of a baby just born, by comparing it with the millions of other photos tagged with "OMG MY BABY IS BEING BORN!," it knows that babies are born in hospitals, and it knows that there is only one hospital in that city, so it guesses that the photo was taken in that hospital.


Also, does the location info purely say "Christchurch, New Zealand" or is it more granular? I'm guessing that when facebook only has sparse information about your location, as in your case, it "zooms out" to the city, state, country etc, but the more information it can collate, the more accurate the suggestion it gives is.


but did you use facebook at all when you were in new zealand?


Indeed but when I posted the pics it was 2 years later from a totally different continent and no reference to the location on the photos.


right, but assuming the timestamp is on the photos, facebook still knows where you were at the time they were taken. The time you upload them is immaterial


In your opinion, how would Facebook know your location if you never logged in from a GPS-enabled smart phone? (and never approved an HTML5 geo permission request on your laptop).

That's the interesting question here.


> In your opinion, how would Facebook know your location if you never logged in from a GPS-enabled smart phone? (and never approved an HTML5 geo permission request on your laptop).

No real trick to that; if the user signs in from an IP leased to a Christchurch, NZ ISP on March 5th, 2007, then it's a safe bet that any photos taken that day were taken near Christchurch (and you get date taken from the EXIF data of virtually every camera on the planet).


well they can do a best guess based on the location of your IP, even if you only sign into facebook once while you're travelling. The really interesting question is: can they do this even if you have not signed into facebook at all on your travels, or for totally new accounts with no location history at all.

If they can, then they must be doing image recognition in some way. Perhaps someone who has more time / energy than me could try this by creating a new account and uploading some photos of recognisable objects (but without exif geo data).


Facebook knows more about me than I do. I'd be interested in their history file of my location.


When you were in NZ: [hh:mm dd/mm/yyyy, nz.ip.address] => [hh:mm dd/mm/yyyy, location]

When you uploaded the photos: [hh:mm dd/mm/yyyy, photo] + above data => [photo, location]


I reckon they use image recognition too. I have a gash digital camera that gets a lot of use; no exif data beyond camera make/model.

Anyway; in 2005 I went on a skiing trip to Chamonix. Pics were uploaded about a month later, no Facebook activity at the time (or while I was there). The other day FB asked me if they had been taken in Chamonix. So... something else used there at the very least.


How does Facebook use image recognition to recognize that an image of a baby on a blanket with no surroundings visible was taken inside a certain hospital? I doubt it.

Regarding your Chamonix images, perhaps your friends uploaded photos taken at roughly the same time, with geo-tags? Perhaps you are tagged in some of them? That would make for pretty simple logic:

- Facebook knows that you were at a certain place a certain time through the geo-tagging of those photos, as your user is tagged in one of them

- You upload photos taken at the same time as the photos you were tagged in

Conclusion: You must have taken those photos where the photos you were tagged in were taken.


Regarding your Chamonix images, perhaps your friends uploaded photos taken at roughly the same time, with geo-tags?

Nope. Family holiday. Of those there I am the only one with photos on Facebook - and in fact at the time was the only family member with a Facebook account :)

I am intrigued because if it is image recognition there isn't much for them to have gone on. But I am stumped for what else they could have used.


Wow. Maybe they have a bunch of people looking at pictures, manually making suggestions? Google "similar images" search-like tool? It does sound scary if they really had nothing to go on other than the image data.


maybe Facebook just randomly guesses locations. those who get matches write comments on reddit wondering how the hell it works and those that get weird suggestions ignore them :)


My photo locations seemed to be mainly based on the album title - I was impressed that it got both locations from "St Catharines and Niagara" correct.

I haven't checked to see if the individual photos are correct. However, at the time I didn't have a smart phone and I'm pretty sure my camera wouldn't provide much useful info.

UPDATE: I take it back: fb thinks I was at a football camp called St Catharines and Niagara! http://www.facebook.com/pages/St-Catharines-and-Niagara/1821...

I think that shows that the title is the most important indicator to fb.


Here's what it looks like the other way round, a PHP framework ported to JavaScript (then swiftly abandoned)

https://github.com/phpnode/YiiJS/tree/master/js/yii


Yeah, there's also phpjs.org when you miss things like strstr() in JS


yeah this port relies heavily on php.js, it's part of the reason it's abandoned, with all the libs it just becomes too big for client side apps, and it sits in some kind of uncanny valley that is really nearly the same as the equivalent php but not quite.


Nitpick: Closures are a 5.3 feature.

The fact is, this is a fancy, but horrible way to construct your objects if you care about performance at all. It also breaks things like typehints, instanceof, inheritance etc.


Thanks for the correction. Sometimes new things feel like they've been around for an eternity ;-)

I absolutely agree with you, that's basically why I wrote the comment. Just looking at their PHP code, you can sometimes see very clearly in what language people were thinking at the time. Some people try to emulate Java, JavaScript, even C or C++ sometimes. It's always horrible.


If we forget about PHP for a while, I really like this way of constructing objects by using dictionaries (or environments or hash tables) and closures.

In fact, I would prefer that in a dynamic language, it would be the only way of constructing objects. I don't see much point in having classes in a language like Javascript, PHP or Python and I almost never use inheritance in these languages. Stuff like instanceof is a bad match for duck typing. Single dispatch method invocation adds very little value to a language that is already ducktyped.


I've been doing this for a while with http://trackmycv.com/ basically you can embed a transparent pixel in an MS word (or any other kind of MS office document) and get notifications whenever it's opened.


http://yaf.laruence.com/manual/yaf.bench.html

it looks like it's about 10% slower than pure PHP, orders of magnitude faster than most frameworks


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: