All posts by memext

Full Binary Tree Theorem

 

The theorem

Let T be a nonempty, full binary tree.

The theorem claims that the number of nodes N, the number of leaves L, and the number of internal nodes I are related in such a way that if you know any one of them, you can determine the other two. Continue reading Full Binary Tree Theorem

Advertisements

Basic typography rules

Basic ratios:

  • Heading font size ÷ Body copy font size = 1.96
  • line height (pixels) ÷ body copy font size (pixels) = 1.48
  • line length (pixels) ÷ line height (pixels) = 27.8
  • space between paragraphs (pixels) ÷ line height (pixels) = 0.754
  • characters per line: 75 to 85

Basic ratios: (Type size = font size)

Attribute Recommended value:
Paragraph width (max-width) = 30 (type size)                          (approx. 65 chars)
Leading (line-height) = type size + (2-5) pt
Vertical rhythm (margin bottom) = line spacing = line height = type size + (2-5)pt

Other rough guidelines:

  1. Either serif or sans-serif fonts are fine for body copy and headings, but sans-serif fonts are still more popular for both.
  2. Common choices for headlines are Georgia, Arial and Helvetica.
  3. Common choices for body copy are Georgia, Arial, Verdana and Lucida Grande.
  4. The most popular font size for headings is a range between 18 and 29 pixels.
  5. The most popular font size for body copy is a range between 12 and 14 pixels.
  6. The optimal number of characters per line is between 55 and 75, but between 75 and 85 characters per line is more popular,
  7. Body text is left-aligned, image replacement is rarely used and links are either underlined or highlighted with bold or color.

 

References:

https://www.smashingmagazine.com/2009/08/typographic-design-survey-best-practices-from-the-best-blogs

 

 

Convert MySQL to MySQLi

Here is a summary:

mysql_connect( ‘host’, ‘username’, ‘password’, true)->mysqli_connect( ‘host’, ‘username’, ‘password’);
mysql_affected_rows -> mysqli_affected_rows($link)
mysql_close -> mysqli_close($link)
mysql_data_seek -> mysqli_data_seek( $result, $offset)
mysql_errno -> mysqli_errno( $link)
mysql_error -> mysqli_error( $link)
mysql_fetch_array -> mysqli_fetch_array( $result, $type)
mysql_fetch_assoc -> mysqli_fetch_assoc( $result)
mysql_fetch_lengths -> mysqli_fetch_lengths( $result )
mysql_fetch_object -> mysqli_fetch_object( $result, $class, $params)
mysql_fetch_row -> mysqli_fetch_row( $result)
mysql_field_seek -> mysqli_field_seek( $result, $number)
mysql_free_result -> mysqli_free_result(result)
mysql_get_client_info -> mysqli_get_client_info( $link)
mysql_get_host_info -> mysqli_get_host_info( $link)
mysql_get_proto_info -> mysqli_get_proto_info( $link)
mysql_get_server_info -> mysqli_get_server_info( $link)
mysql_info -> mysqli_info( $link)
mysql_insert_id -> mysqli_insert_id( $link)
mysql_num_rows ->  mysqli_num_rows( $result)
mysql_ping -> mysqli_ping( $link)
mysql_query -> mysqli_query( $link, $query)
mysql_real_escape_string -> mysqli_real_escape_string( $link)
mysql_select_db – > mysqli_select_db( $link, $database)
mysql_set_charset -> mysqli_set_charset( $link, $charset)
mysql_stat -> mysqli_stat( $link)
mysql_thread_id -> mysqli_thread_id( $link)

 

 

Great reference:

https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html#convert