Archive

Archive for the ‘web’ Category

Format your json with userscript

September 8th, 2011

I have created a very small userscript for opera (might work ok with other browsers) that formats /indents/ beautifies the JSON data in a document if it’s only JSON there.

For opera to open the JSON by itself and this to work (the default is to present it as a download), you will have to enable that in opera. Go to preferences -> advanced -> downloads -> Add

Mimetype: application/json
Select open with opera

That will result in your JSON looking like this in the browser:

// ==UserScript==
// @name 		   JSON formatter
// @version        1.0
// @description	   Formats JSON if the document only contains JSON
// @compability    Only tested with Opera, might work with others
// @author		   Martin Hansen
// @website        http://martinhansen.no
// ==/UserScript==
(function(){
	var indentation = 4;//Change this to vary the indentation

	var pre = document.querySelector('body pre:only-child');
	if(!pre) return; //Don't do anything if this don't seem to be a json only document
	try{
		pre.innerHTML = JSON.stringify(JSON.parse(pre.innerHTML), null,indentation);
	}
	catch(e){
		console.log(e);
	}
})();

Either save the sourcecode directly from here, or get it from userscripts.org

Martin Javascript, opera, web

HowTo: Set google “I’m Feeling Lucky” as default search

October 23rd, 2009

URL’s suck.

When I want to go to Google calendar I want to type just that, or even google cal. Instead of Google dot com slash calendar. When I want to see today’s episode of Colbert report, I should be able to type that in the address bar even though the address is colbertnation dot com.

Enter Google’s “I’m Feeling Lucky” search. Below is a guide to set Google’s “I feel lucky” as default search in various browsers:

Opera:

  • Open Google.com, or your favorite Google page.
  • Right click the search field and select “Add custom search”
  • Click details, in the address field you will see something like this:

http://www.google.com/search?hl=en&source=hp&q=%s&btnG=Google+Search&aq=f&oq=&aqi=

  • Now, change btnG=Google+Search to btnI, so it looks like this:

http://www.google.com/search?hl=en&source=hp&q=%s&btnI&aq=f&oq=&aqi=

  • Finally check “Use this as default search engine”

Chrome:

  • Enter options -> Basics ->Default search section, click manage.
  • Select the already existing Google search, click edit, copy the URL.
  • Close, and add new.
  • Type a name and, leave keyword empty, and paste into the URL that which you copied and add &btnI, it should be something like this:

{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}sourceid=chrome&ie={inputEncoding}&q=%s&btnI

  • Click ok, and then set as default.
  • You can still search with Google by typing  the keyword (google.com) and then you’ll see the search appear under the address bar.

Martin Uncategorized, web , , ,

IIS and skype = trouble

October 20th, 2009

Do you have a problem starting a website on your developer machine but you get an error saying something like:

The process cannot access the file because it is being used by another process?

Is your website set to run on port 80?

Then ask yourself, are you running skype? If so, skype is probably the reason for this error. Skype is by default configured to use port 80 and 443 as alternatives to the standard port. Remove that under Settings -> advanced -> connections -> Use port 80 and 443 as alternatives for incoming connections.

I always seem to get that error whenever I do a reinstall of windows etc. but it always take me 5-10 min to realize that is the error :P

Martin web ,

Will Opera reinvent the web?

June 12th, 2009

Recently Opera invited webdevelopers and journalists to a video conference next week, at the 16th of june, 9 AM CEDT.

They also have set up this page http://www.opera.com/freedom/ where they say they will reinvent the web. To be honest, even though I’m a Opera user myself, I do feel like they are setting us up for a disappointment. But that remains to be seen. They sure do use big words though.

If you take a closer look at the source code for that page you can read a story where they are hinting to what this news is. Also they have a meta tag with keywords such as “new browser, beta”.

The other hints, the story, are inserted into the page as comments, they started out with just a few words, now as time goes on they add more and more to the story. I will post here on this site the story as they continue to add to it. This is what we have so far:

We start our little story with the invention of the modern day computer.
Over the years, the computers grew in numbers, and the next natural step in the evolution was to connect them together. To share things.
But as these little networks grew, some computers gained more power than the rest and called themselves servers.
Today, millions of people are connected together in a great web …

My quess is they will release some kind of P2P interaction between users of Opera, and probably other browsers if they release it as an open standard. But time will show :)

Final story:

We start our little story with the invention of the modern day computer.
Over the years, the computers grew in numbers, and the next natural step in the evolution was to connect them together. To share things.
But as these little networks grew, some computers gained more power than the rest and called themselves servers.
Today, millions of people are connected together in a great web. But now we want to do more than sharing.
We want to collaborate, get together, look at the same things and be united in new ways.
We want our computers to be able to do more things than the servers.
At Opera, we want to put YOU on the web, so that you can interact directly with who you want. How you want.
A serverless and cloudless interaction. Direct, fast and private.
Welcome to Opera Unite. The next version of the web.

Turns out I was right, not that hard to guess though. Opera unite is not that interesting in the fact of the existing services that are there, Opera even says those might be removed for the final version. The interesting fact is that developers can create services that users can take advantage of. Head over to the dev section for opera unite to read more.

Opera unite is trending 2nd on twitter at the moment, only second to #IranElection, but I think Opera would be wise to release opera unite as an open source project allowing implementation into other browsers. Just change the name ofc :) Because Opera’s market share is so small the whole idea of “reinventing the web” and changing the structure of the web could fail because of that.

But I guess we’ll just have to wait and see. Opera has had a good year, money wise, and their mobile products is doing better that ever. So I do not think they are hoping to take over the market share this way, but it might give them an increase.

Martin web