Calculating Rates

One of the main differences in going truly freelance* is having to have a consistent formula for calculating quotes and pricing for jobs, as for most things this basically comes down to a time and materials calculation, but the time part has a load of variables in its own right, So far these seem to me to break down into the following

“Basic” = This is the hourly rate you would pay for a permanent member of staff who could do the job to the competency you require.

This is our baseline, it represents the ultimate “bulk buy” and so offers the cheapest rate but is the least disposable.

“Contractor” = “Basic” + A pro rata amount representing all the stuff that a permanent would normally get as part of their job e.g. Holiday, Pension, Sickness, Insurance, job security etc etc

In actual fact a contractor tends to cost the same as a permanent in a holistic way, it is just that you see all the costs up front, more expensive but also more disposable than a permanent member of staff

“Consultant” = “Contractor” + Business over heads (such as travel, time lost, project overruns and changes)

Consultant rate is in fact a reverse form of “bulk buy”, you are only paying for people for a short period of time so they have to maintain them selves when you have finished with them before they pick up their next role, consultant rates also tend to cater to sudden client demands and changes, very often when you see a project start to get picky about every change and alteration, it is because the project has been aggressively priced according to “Contractor” rates (either because of rate negotiation or competition) which means every time there is a change it ACTUALLY costs the consultant money

“Jump” = “Consultant” + Cost of Impact to other clients

More properly called “On Call” or “SLA Maintenance” rates, “Jump” rates mean you stop what you are doing and immediately attend to the needs of a client, you see them all the time in the different costs associated with a support contract, you have to consider the impact to other clients if their work is interrupted and if that is not permitted, someone must be constantly waiting for a client to make them “Jump to it” which cost money, of course many large clients expect “Jump” performance for “Contractor” Rates, so you must decided if such business is worth the Loss leader Behaviour that this represents

Of course you can throw all of this out of the window due to a number of reasons e.g. Really Interesting work, Worthy cause or to improve your skill set.

So this is what proper managers do…………

*That is having no one main client but lots of nearly equal clients.

Salesforce read mode hide-when hack

It seems the need for hacks has not gone away with the move to cloud, but you do have to be more careful, as I have already found out Salesforce can break your custom code at will.

So that being true one of the things that SalesForce does not seem to have that every other framework does is a simple an powerful “hide when”, IMHO this feature should be present in every line button and object on every page and most platforms do,

It is the most requested feature for customisation that I have come across, and this is the hack that I use for read mode documents or forms (which strangely is where the request is most often made) (and yes it is a hack)

We are going to just stuff some JavaScript into a apex page, you can see an example of it below

<apex:page standardController="Case" showHeader="false" sidebar="false">
<script>
myVar = checkforbutton();
function checkforbutton()
{
    if (typeof(parent.document.getElementsByName("searchArticles")[0]) != "undefined" )
    {
               if ( parent.document.title.indexOf("Customer Community") != -1) {        
                   parent.document.getElementsByName("searchArticles")[0].style.display = "none"; 
               }
    }
    else
    {
            window.setTimeout("checkforbutton();",100);
    }
} 
</script>
</apex:page>

Lets break it down
1. We have to use “parent.document” to get JavaScript objects as when we use this page [SalesForce](http://www.salesforce.com/) will embed it inside a Iframe
2. We have to do a wait loop that keeps looking for the object till it finds it (then stops), because [SalesForce](http://www.salesforce.com/) adds button objects in after the page loads so they wont be there when it first opens

    if (typeof(parent.document.getElementsByName("searchArticles")[0]) != "undefined" )
    {
            //do stuff
    }
    else
    {
            window.setTimeout("checkforbutton();",100);
    }

3. When the button is confirmed to be there then we are going to check the page for a condition(s) and if it’s true/false we are going to hide the button/element on the basis of it, in the above example, if we are on the “Customer Community” version of a page, we don’t want to allow the users to search for articles, so we hide the “searchArticles” button, it’s not a security issue, we just don’t want to confuse the user experience by allowing this feature.
So we put this code into a Page

This insert that page into the layout Object layout we want it to effect.

that would normally give a big white space where the inserted form lives, so we make the page a 1% by 1px block

And that’s it, just save the layout, the button/”what ever” will hide when the page loads, a hack but a simple reliable hack
Now as always “hide when” is not security, remember to make sure that you don’t leave functions exposed and think this kind of thing covers you.

Classic Domino and multi country dates with Bootstrap

I was doing some fixes on a classic domino web app that uses bootstrap datepicker when an issue was raised. turns out its a bugger to get the jquery datapicker and domino date format to agree with each other for different countires ie mm/dd/yyyy or dd/mm/yyyy or dd.mm.yyyy

you would think that a little bit of JavaScript would solve the problem but there was multiple instances with a variety of browsers where it ended up that what ever domino was doing to calculate the date format was not matching the result of the JavaScript.

So we cheated, we replaced the “format:” parameter in the date picker below:

$('#MYDATE').datepicker({
    format: "mm/dd/yyyy",
    clearBtn: true,
    orientation: "top auto",
    todayHighlight: true,
    autoclose: true,
    weekStart: 1
 });

with some computed text with the following formula:

dat := @Text(@ToTime("01/28/1900");"D0S0") ;
sep := @Middle(dat ;2;1) ;
@If( @Left(dat; 2) = "28" ; "dd" + sep + "mm" + sep + "yyyy" ; "mm" + sep + "dd" + sep + "yyyy")

I find the best way is to put this in the default setting meaning you only have to do it once

$.datepicker.setDefaults({
     dateFormat: '<Computed Value>'
});

Simple, worked fine with a wide variety of date formats and kept everything in sync with what ever format Domino ended up picking.

Adventures in Japan 2015: Conclusion

I sit here at the end of my first proper holiday in nearly a decade, my long awaited honeymoon and a trip to a place that has literally been the land of the rising sun for my entertainment since I have been a child.

and what did I think of it?

 

Japan did not disappoint in any way, the culture, the people, the city’s, everything lived up to my dreams

I could have wandered forever through the country and indeed never have I more wanted to pack up a ruck sack and travel as I did after seeing the green of my first bamboo forest.

The Japanese have taken so much of the west to their heart, but they have made it brighter and more Kawaii and in doing so have made it theirs, all the time maintaining their own gorgeous traditional culture.

Some of the things that made Japan so amazing could only exist in Japan as frankly we in the west sometimes just cant have nice things as we demand our right to screw them up, and thus we cant do crowding without pushing or have clean trains that don’t stink, I’m aware that I might find it hard to live with some of the rigged social normals the Japanese do, but its still a wonderful country.

We WILL go back

 

Adventures in Japan 2015: Food

I approached Japan with some trepidation food-wise as I can’t read the language and also fish stock tends to be put in to a huge amount of the savoury things. However it seems that it is not hard at all to find stuff, and in the major cities there is a real vegetarian/vegan movement (they have meetings and get-togethers and all sorts)

The best app for finding good places to eat was Happy Cow which found all the places to eat we could want. Although you do have to apply a bit of sanity to its directions as they are not allways right

Japanese restaurants and places you sit down to eat in tend to shut down between about 4:30pm and 5.30pm and those that do not tend to run a much reduced menu so that is something to be aware off.

Vending machines serve nearly all your drink needs be it a morning coffee or a full bottle of whiskey and all at a good price (starting at 100yen), nearly everything else is handled by the Family Mart chain of stores, Family Mart is also where you will find the cash machines.



Curry and great ramen at T’s TanTan Tokyostation hidden inside Tokyo station meaning finding it the first time is a bugger and you can’t get to it for free as its behind the ticket barriers, but well worth a diversion or to plan your travel round.



With a rich tangy taste I ended up having 2 of these at one sitting and the memory still makes me drool. found at http://www.hanada-rosso.net/



At the time this had to have been the best vegan pudding I have ever had, and would give most none vegan puddings a run for their money found at Cafe Atl in Osaka (a very nice place if a bit pricey )



Also at Cafe Atl A light pleasant orange flavoured beer went down very nicely thank you



The best place we went in Osaka was Paprika Shokudo which not only serves amazing food and puddings to die for, but were chatty and helpful with suggestions on other places to eat along our travels, I could have eaten there every day!!. They served the greatest pudding I have had since becoming a Vegan, but I did need a lie down after wards



Armed with only a vegan food festival, a local store and a box of preparation I was able to make a sandwich. is there no limit to the genius




Double bite sized pockets of Tofu stuffed with sweet plain rice with some ginger on the side were my default snack and could be got at just about every corner store



There ARE supermarkets in the cities just a bit harder to find that you would expect, we seemed to find them on the top floor of other buildings or department stores.



These slabs of fluffy tofu have a very similar texture to omelets (and you do have to be careful as there are pre done omelets in the shops) they make great fillers for bread or anything really and can be got from just about any shop (we made a lot of sandwiches with them)



Vending Machine with Whisky and Sake in them, not vandalised! NOT VANDALISED!!

Vending machine on every corner and unlike UK ones NOT a rip off

References

References
1 transform src="/assets/img/blog/XXXX" width="740" action="resize"

Adventures in Japan 2015: Osaka / Kyoto

Osaka is WAYYY better than Tokyo from my point of view. Tokyo is like a massive London but with cultural differences, Osaka was like nothing I had ever been to before, it felt like a different country (yeah yeah I know it already was a different county, but Osaka FELT different). As a child of Skegness I have always loved cheap neon and that gaudy fun feel, and this was everything I could have wanted, busy like a festival but not pushy or filled with drunk idiots or thieves, it was an utter joy to wander round.

Kyoto on the other hand was pure history and culture (plus all the tourist trappings that always surrounds such things) and as the two cities are only a short trip between each other they are a good to compare as a set.



Like you hope it a Japanese city will be

Every shop and stall was dressed up to the nines and fun to look at



Normally in a western country this many people would be nasty grumpy and pushy, here there was no indication of that, people were aware of those around them and did not hold up traffic, made the whole experience better for all.

God I miss the bright vibrant Arcades of my youth, it was like coming home

The Tsūtenkaku Tower a well know land mark which helped with the chaotic navigation of Osaka



A REAL Bamboo forest, just sat there errrr… Growing



Behind this door were two of my personal bucket list items, an amazing traditional Japanese garden off a tradition veranda, and a Nightingale floor but alas no photos inside, you can see details about them here



Reading up on what went into the architectural marvels that were the Japanese Pagodas was amazing. part building, part art form, part ritual

You could image a small god living here

 

Panoramic of the Gardens at Daigoji Temple, Japan put on a perfect day for us with few people around and no queues to wait for anything (happy sigh). Note: the pop-up image for this may take a while to load as its 8Meg

We decided that a trip to the fun Fushimi Inari Shrine was in order as it is one of the really popular temples attracting millions of visitors a year



The Foxes that guard the template and act as messengers all look more than a little p**sed (understandable as everybody is always asking them for money)



That is a 4k hike over the mounting that you are looking at, priests are fit devils here.



The Torii or Gates start here



And Just keep going!!!



Companies buy them (Inari is seen as the patron of business) but they are NOT cheap

References

References
1 transform src="/assets/img/blog/XXXX" width="740" action="resize"

Adventures in Japan 2015: Tokyo

Tokyo is far cleaner and safer than you would expect even if you have been told about it, women walk seemingly unafraid down dark alleys and litter seems to be an endangered species, but you do have to be more aware of your surroundings, several times I turned round to discover my lack of attention had lead to a queue of 10+ people waiting for me to get a grip and start moving again.

As a city Tokyo was the first one I had been too that felt much larger than London, unsurprising at its population is 13.4 million vs London’s 8.5, we went to at least 5 districts that could have easily passed for the city centre and all of them were packed.

We barely touched on what Tokyo had to offer (avoiding all traditional culture in Tokyo on this trip), however the artificial island of Odaiba was my favourite day



Tokyo had about 4 or 5 areas (it may had had more but we did not get to them all) that are like Times square or Piccadilly filled with neon and all dedicated to a different purpose




Akihabara anime central for the WOOORLLDDDD



The national Kabuki theatre, looks nice but a bit too rich for my blood (loads of other stuff to see)



Living space in Tokyo was a strange mix, rooms and such were very small but they seemed to confine this to only certain areas: corridors, pavements and gardens were all spacious and appear in the strangest places, it made walking through even the poorest areas a pleasant and sunny experience.



Look at this road, clean, no rubbish but Ivy is still allowed to spread, a mixture of nature and modern life we rarely see in the west (its the little things)

A real Sacred Tree, its Anime made real!

The gateway to the massive Meiji Shrine, we never got past the outskirts on this trip but next time we will dedicate the time it deserves.



A view from the automated rail, how can this be a capitol of a major world power, it’s so clean it looks like a model.



“Up from the depths, Thirty stories high, Breathing fire, His head in the sky” …… MY HERO!!! <3



I like a nice subtle sign post, nothing flashy or showy :p



For those who think that the Japanese regard Anime as just a fringe interest you may be wrong. To them its bigger than Disney is to Americans

This is a SEGA foot massage machine in an arcade, you get little plastic bags to put your feet in to keep everything clean and it works really well (but I have to say I could not follow the instructions)

Now this is how you do a show trailer!!! the whole set lit up

I have seen these before but this was the best use of space and the first flip one that I have ever Seen

References

References
1 transform src="/assets/img/blog/XXXX" width="740" action="resize"

C3 charts on Saleforce Winter16

As @devinthecloud points out in his Blog post Salesforce Winter 16 wrecked C3 charts on the pages he and I had developed. he found the removal of <apex:form> fixed the issue on his pages, but on my page the charts were still broken, so instead of this:

 

 

You get this

 

 

I stripped the page down to a bare minimum that you can use to recreate the issue, see below,

<apex:page docType="html-5.0" 
           applyBodyTag="false"
           showHeader="true"
           readOnly="true"
           sidebar="false">
<html lang="en">
  <head>
      <!-- Static Resources for CSS -->
        <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css" rel="stylesheet"/>
    </head>
    <body>
      <div id="chart"></div>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js" />
      <script>
        var chart = c3.generate({
          data: {
            columns: [
  //            ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
              ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3],
              ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8],
              ["setosa", 30],
  //            ["versicolor", 40],
  //            ["virginica", 50],
            ],
            type : 'pie',
            onmouseover: function (d, i) { console.log("onmouseover", d, i, this); },
            onmouseout: function (d, i) { console.log("onmouseout", d, i, this); },
            onclick: function (d, i) { console.log("onclick", d, i, this); },
          },
          axis: {
            x: {
              label: 'Sepal.Width'
            },
            y: {
              label: 'Petal.Width'
            }
          }
        });
        setTimeout(function () {
          chart.load({
            columns: [
              ["setosa", 130],
            ]
          });
        }, 1000);
        setTimeout(function () {
          chart.unload({
            ids: 'virginica'
          });
        }, 2000);
      </script>
    </body>
</html>
</apex:page>

 

This let me narrow it down to the Salesforce header.
when you set **showHeader=”true”** it breaks
if you set **showHeader=”false”** it starts working
As this is obviously and provably down to a change in winter 16 I can raise it with Salesforce and get a fix.
…….. Wrong!
I quote

“At times, Client Side JS conflict with SFDC header JS will collide with already defined functions with the same name.”

“the behaviour of JavaScript is inconsistent with Salesforce components.”

and

“as we don’t support JavaScript”

Ah it’s nice to see that young Internet companies have the same grasp of customer service as the traditional IT companies and thus it falls back on consultants to fix, in this case with an Iframe, I’m not a fan of Iframes normally but as Salesforce use them themselves there is precedent
And so we now split our single page into 2 pages, an inner content and an outer Iframe wrapper
First we take out the existing page (it was called **”chart_test”**), rename it to **”chart_test_inner”** and set **showHeader=”false”**
Then we put in a Iframe wrapper with the old name and a bit of CSS to make it size properly then point it to the inner content

<apex:page docType="html-5.0" 
           applyBodyTag="false"
           showHeader="true"
           readOnly="true"
           sidebar="false">
<html lang="en">
  <head>
  <style>
  .fluidMedia {
    position: relative;
    padding-bottom: 56.25%; /* proportion value to aspect ratio 16:9 (9 / 16 = 0.5625 or 56.25%) */
    padding-top: 30px;
    height: 0;
    overflow: hidden;
  }
    .fluidMedia iframe {
        position: absolute;
        top: 0; 
        left: 0;
        width: 100%;
        height: 100%;
    }
      </style>
  </head>
    <body>
    <div class="fluidMedia">
        <iframe src="../apex/chart_test_inner" frameborder="0" > </iframe>
    </div>
    </body>
</html>
</apex:page>

 

And now instead of a broken

We have a working

Hooray!!!