Author Archives: Anu

arc() method

During Coding Math lessons context.arc() was used and I didn't know which arguments it used. Arc is a section of circle and it's defined by:
  1. x-point
  2. y-point
  3. radius
  4. starting angle
  5. ending angle
  6. direction of the arc
  7. x and y point define the center of the circle. Radius is for the distance from the center point and direction can be clockwise (false) or anticlockwise (true). In this example radius is 10 and last argument is clockwise (false).

    See the Pen arc() method 1) by AnuVi (@AnuVi) on CodePen.

    In this example I changed the anticlockwise to true and radius is 50.

    See the Pen arc() method 2) by AnuVi (@AnuVi) on CodePen.

    More info HTML5 Canvas Arc Tutorial

FB Like-box to be responsive

Add parent element to .fb-like-box, eg .like-wrap In you HTML:

 
And in your CSS:
.like-wrap{
  width:100%;
}
.like-wrap * {
  width:100% !important;
}
* selector selects every child element in .like-wrap.

substring()

Task was to insert into the database next invoice number. The problem was that invoice number looked like this MB-13. I needed this account number in two pieces MB-- and the last biggest number. In MySQL there is a function substring() and counting starts from 1.
$latest_invoice = mysql_query('SELECT SUBSTRING(Invoice, 4) FROM table WHERE Invoice LIKE "%MB-%"');
Now how to get the biggest number? Tried this:
$latest_invoice = mysql_query('SELECT MAX(SUBSTRING(Invoice, 4)) FROM table WHERE Invoice LIKE "%MB-%"');
It gave 99. But it was wrong, it had to be 255. Invoice number was in a string-format, but I needed a number. Solutions: 1) - add 0 and MySQL automatically converts it.
$latest_invoice = mysql_query('SELECT MAX(SUBSTRING(Invoice, 4) + 0) FROM table WHERE Invoice LIKE "%MB-%"');
The result was my needed 255. Now I had to add 1 to get the next number, but PHP treats it still as a string. To convert to number, as I needed only full numbers, I used (int).
  
2) Use only number part of the string — I know that first three characters in my string will always be MB-.
$latest_invoice = mysql_query('SELECT MAX(CAST(substring(Invoice, 4, length(Invoice)-3) AS UNSIGNED)) FROM table WHERE Invoice LIKE "%MB-%"');
and in PHP only add 1:
  

Chorme Developers Tool tips

At the moment I'm taking Udacity's course Mobile Web Development and in Lesson 2 there were some good tips about Chrome Developers Tool.

[caption id="attachment_122" align="alignnone" width="754"]Chrome Developers Tool color checkbox If you hover color's checkbox - the hint is there.[/caption]

  1. Click on color's checkbox, it opens colorpicker and you can play with colors directily in your browser.

    [caption id="attachment_126" align="alignnone" width="804"]You can test colors using Chrome Developers colorpicker You can test colors using Chrome Developers colorpicker[/caption]

  2. If you press SHIFT and click color's checkbox — it changes color format: hex → rgb → hsl.

  3. If you click on any numerical value and use your mouses's scroll — you can change it as you wish, smaller or bigger.

a

Scanning someone else's code noticed that kind of thing:
+ 372 55 555 555 

It turns out you can set your mobile–browsers to call out. If you click it on standard browsers it gives you an error. So, at first you have to detect the browser.

Alt

The straight answer? Use alt text; if an image is decoration then implement with CSS; if a decorative image is still inline or has no added value, use alt="", with no space. (Hint: repetitive content has no value.) If an image is linked, it must have alt text conveying the meaning of the link (and not necessarily the image itself).
http://www.webaxe.org/leave-accessibility-to-experts-please/