11 5 / 2012

Today a workmate of mine wanted to redirect a site to its language specific sub-site using JavaScript. I don’t know of a way the browser exposes the set language but I once read a snippet in the SharePoint source. I have a tendency of just copying OOB SharePoint JavaScript into a oneNote for the fun of it.

I will in another post blog about the specific function that exposes the site set language. For now here is how you can get the current set language in SharePoint.

var currentSetLanguage = _spPageContextInfo.currentLanguage;
var curentSetWebLanaguage =_spPageContextInfo.webLanguage;

In my case both return ‘1033’. Now 1033 is just a language code, so I googled for language codes and found the official link to Microsoft specific language/local codes

Knowing the language that’s set you could then do a redirect or WHY like this:

$(function(){ 
var languageSett = _spPageContextInfo.currentLanguage;
if(languageSett !== 1033){
document.location.href = "/sites/germany/default.aspx";
} else(languageSett == 1033){
return false;
}
});

That’s it, look forward to my post on other functions I also discovered

@NerdGr8

07 5 / 2012

You can clean up console.log() to just log() quite easy. Didn’t know but knew you could. Here is the awesome snippet that will have you save 8 characters every time you want debug something. Instead of typing console.log() just type log(). Neat it is I know.

 window.log = function f(){ log.history = log.history || []; log.history.push(arguments); if(this.console) { var args = arguments, newarr; args.callee = args.callee.caller; newarr = [].slice.call(args); if (typeof console.log === 'object') log.apply.call(console.log, console, newarr); else console.log.apply(console, newarr);}}; 

Love it use it! Read how its done make it better


07 5 / 2012

Having had a bad time with console.log() I woke up today and read an awesome email from @jquery4u which included something that You and me would dearly love. Like I mentioned in my other post console.log() really causes issues in IE if console is disabled. You wouldn't want to deploy a site with a tiny line of console to production as that will break all your java script stuff.



(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());


02 5 / 2012

Microsoft is not a software development company its a business and therefore a Software sales machine. Selling is what they know best. Unlike what most people think. Microsoft is by far the most interesting company of all time. Google on the other hand the most irritating “Start-up” of all time. Apple well an old company that recently bubbled back to life after sniffing the grave.

Read More

02 5 / 2012

Its not different to any other day were I wake up with predefined problems to solve. Today its about the three big social networks, Twitter, Flickr and Facebook.

On a project we worked on at work we recently had to move the site over to HTTPS and with it came a few awesome bugs and issues. Part of them was the social widgets not showing or working over SSL / HTTPS . Bellow is the solution

Twitter widgets not working over HTTPS.
Couldn’t solve it on SharePoint but in case this might help you. There is a bug listed on the twitter developers site already. They suggest you change the link to the widget to https://widgets.twimg.com/j/2/widget.js

Flickr widget not showing automatically over HTTPS

I just added https://secure.flickr.com that should do the trick. It will automatically show the images in IE9 without showing the security prompt.

Facebook widgets not showing over HTTPS in IE9
Like many of you know by now I work on SharePoint and that means IE is a crucial browser and in most cases the only browser I know and use. Because of the no protocol mix security issue. You shouldn’t at all mix secure and no secure content on the same page unless you want IE to shame you when users visit your site. Now Facebook widgets can be served over HTTPS and HTTP, if you have the iframes being pulled from http:// currently then even when the user allows the page to show all content you might have realized FB’s widgets are not shown even in this scenario. Well add https://www.facebook.com/plugins/likebox.php to all of them. You will realize that still the user has to approve all content to show. This is because you are serving the iframe over HTTPS and the contents of the page e.g photos are still shown and served under HTTP, :-( that means certain elements wont show. I’m still to investigate how to serve everything by HTTPS on load.

30 4 / 2012

Just like and other PHP developer I have over the past week been trying to get my wamp working after I installed i think Skype and WCF. Every time I click on the darn launch icon I eagerly awaited the green light and to my disappointment the icon decided not to give me the Green blessing.

Now here is something Im sure you have done already. Googled for a solution and only found Bloat posts blaming good old Skype. Well yes that is true and I suggest you check your advanced setting under options if the use port:80 is unchecked. I’m sure you have done that already. Now lets continue to my solution which wasn’t solved by that.

Solution
Left click on the wamp icon and under Apache click on httpd.conf . If you know how to get to the file better still.
Now the issue is that some program which I could identify is listening to port:80 and you need to either stop it or do the following
Search httpd.conf for “Listen 80 and change 80 to 2000 or any number higher than 1064


I got mine working I’m sure yours should work now. if not hit me up on twitter @NerdGr8

30 4 / 2012

Without realizing today was not a Holiday back here in SA. I kept my lazy body in bed and realized quite late that It wasn’t a holiday and had to jump out of bed in rockster like motion. Got to work like any other day wrote some jQuery, closed all my bugs. Just in time for my MD to test and alas, something seems broken! Oh flip same excuse again “it works on my machine!”. Egg in face moment, two other avid IE9 users also fail to see my changes.

Here is why that happened. Like any other developer we all love using console.log() and all other console specific functions. They are quite useful to a developer yes but not as useful to a non developer in IE9. IE9 will run all your JS normally if you set a break-point on the script you are running. The script will only run if developer tools is enabled or if you at least set a break-point on part of your js. If you don’t then IE9 wont run anything in your js file.

I don’t know why but I learnt the hard way and discovered just how awesome Developer tools is. Although some would shoot at Microsoft for it. I personally adore the fact that you shouldn’t have debug messages running in production anywhere so shoot yourself!

FIX
Remove all console calls and everything will work fine or just comment them out.


29 4 / 2012

Just woke up to a few tweets from the great @symarc and while browsing my way into blog goodness I ran into a nice post by

What I really thought I could reblog is the feature I didnt know about webparts. We all hate working with the default webpart chrome. I personally have to always hide them on custom branding projects. Although they serve a good purpose its not always that we need them.

A Quick tip on how to remove them automatically by default is to add the following attribute to your web part zone.

PartChromeType="none"

That being a built in attribute you still can manually reshow the webpart chrome manually on any webpart making it awesome!

Enjoy

24 4 / 2012

Over the past month I have had to work with more and more Query strings. Being one who has for long relied on SharePoint’s built in Query spitting and munching capabilities I have had to revise and redo my location.search syntactical approaches. Today after a Stack Exchange conversation which I failed to reply to in time :-( to get my green tick I have resorted to blog my a better implementation of Query string munching in Javascript. Pure JS goodness. Furnish yourself with the awesome function.

 function ExtractQueryString() { 

var stringResult = {};
var aQueryString = (location.search.substr(1)).split("&");
for (var i = 0; i < aQueryString.length; i++) {
var aTemp = aQueryString[i].split("=");
if (aTemp[1].length > 0) {
stringResult[aTemp[0]] = unescape(aTemp[1]);
}
}
return stringResult;
}
//Usage
var stringValue = ExtractQueryString();
alert(stringValue.name);

Munch those Query string value pairs with ease. Bless

24 4 / 2012

takunda:

Wars for colonial liberation have scarred generations with a ripple effect that’s going to be there for the next couple of generations. Africans are literate: they know english, drive cars and have Facebook accounts but tertiary education or working from a desk has never stuck in the head.

But once education sticks in an African’s head (s)he will never again attempt a startup because of the cozy comfort of employment. And they also cease to learn from that point: A reality in all industries.

Actually there is nothing in education that hinders one from starting a start-up or inspiring one to start a start-up. The misconception of start-up is that running or starting a start-up is a practice of school drop outs!

Start-ups are more profitable in the excess of an educated starter not the other way round. The art of starting up is overly exaggerated and clouded by the success of African irrelevantly successful individuals. Here in Africa you need to work behind a desk to get money into your mouth or else you die. In Europe its a different ball game. They get money in all directions and they Venture Capitals shot at them here in Africa you go around licking and looking for VC’s. Twitter for example was start with no money and is still not making money but Is undoubtedly the best Start-up success story. If Twitter was found in Africa they would have long bailed out. Investors here want their money back and if a company is not making money they don’t bother looking at it.

Africans need to be educated unlike most. Education is key and being a company that teaches you business is ever critical to success. Business is not a school drop out excuse so are start-ups. Zuckerberg dropped out in University so are allot of them and because they became successful they could afford the ignorance coz they could hire efficiently qualified team, players.

Here in Africa go to schoool!! work !!!! be educated!!!