Screen Resolution - Web development

Link: http://gs.statcounter.com/

I have used the statcounter for several years to help me adjust page layouts for web development.

The mistake I have been making is that the browser does not usually have the entire screen resolution available.

Today I took some time checked the window dimensions on a Windows 7 laptop with a 1366x768 screen and several browsers.

Firefox

  • Full screen with menu and bookmark bar 1366x608
  • Windowed, full height x600

Internet Explorer

  • Full screen with menu, bookmark, DebugBar 1301x548
  • Windowed, full height x540

Chrome

  • Full screen 1366x667
  • Windowed, full height x639

These dimensions depend on the toolbars in use, etc, but they provided a very helpful reminder that 1366x768 screen resolution is not the same as a 1366x768 browser page.

In addition, the best way to test a page under Internet Explorer is to use Internet Explorer, and if you you need to test different versions (you do!), you can use IE or IETester (http://www.my-debugbar.com/wiki/IETester/HomePage). Sometimes there is simply no substitute for target machine and browser testing.

eZ Publish - Adding Bootstrap Glyphicons

If you are using Bootstrap with eZ Publish, you can add a custom tag to include glyphicons which will allow editors to add the icons into their content.

This is a simple implementation, it allows the user to enter the name of the icon they would like to use.

content.ini.append.php

Code

<?php /* ini charset="utf-8"
 
[CustomTagSettings]
AvailableCustomTags[]=glyphicon
IsInline[glyphicon]=true
 
[glyphicon]
CustomAttributes[]
CustomAttributes[]=name
 
*/ ?>

The template HTML must match the Bootstrap version in use.

design/site/templates/content/datatype/view/ezxmltags/glyphicon.tpl

<!-- Choose the HTML for the tag based on the version of Bootstrap you are using -->
<span class="glyphicon glyphicon-{$name}"></span>

<!-- or -->

<i class="icon-{$name}"></i>

eZ Publish - Object Relation Attributes - Reckless Cleanup

Link: https://jira.ez.no/browse/EZP-19183

This is NOT A FIX for the code, but if you are getting confusing results for queries due to relationships between object relation attributes which were deleted from content classes, you may use this query:

Backup your database first

This is not for the faint of heart

There are no warranties or other guarantees - use this at your own risk.

DELETE FROM ezcontentobject_link WHERE contentclassattribute_id != 0 AND NOT EXISTS (SELECT * FROM ezcontentclass_attribute WHERE ezcontentclass_attribute.id = ezcontentobject_link.contentclassattribute_id);

Twitter Application Auth Sample - PHP

Link: https://dev.twitter.com/docs/api/1.1/post/oauth2/token

This is a sample PHP code which can be used to get a Twitter OAuth token for use in making API calls.

It includes a trends available request that gets the list of countries for which Twitter trends are available.

Be sure to read the documentation at the link above. A given application can only have one token at any given time, so once established, the token should be stored and reused.

PHP

$consumerKey '-- YOUR CONSUMER KEY --';
        $consumerSecret '-- YOUR CONSUMER SECRET --';
        $encodedKey urlencode($consumerKey);
        $encodedSecret urlencode($consumerSecret);
        $bearerTokenCredentials $encodedKey.':'.$encodedSecret;
       
        $ch curl_init();
        curl_setopt($chCURLOPT_URL'https://api.twitter.com/oauth2/token');
        curl_setopt($chCURLOPT_POSTtrue);
        curl_setopt($chCURLOPT_POSTFIELDS'grant_type=client_credentials');
        curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        curl_setopt($chCURLOPT_HEADERfalse);
        curl_setopt($chCURLOPT_ENCODING'gzip');
        curl_setopt($chCURLOPT_HTTPHEADER,
                array('Content-Type: application/x-www-form-urlencoded;charset=UTF-8',
                        'Authorization: Basic '.$base64BearerTokenCredentials));
        $result curl_exec($ch);
        $error curl_errno($ch);
        if ($error === 0) {
                $json json_decode($result);
                curl_setopt($chCURLOPT_URL'https://api.twitter.com/1.1/trends/available.json');
                curl_setopt($chCURLOPT_HTTPGETtrue);
                curl_setopt($chCURLOPT_POSTfalse);
                curl_setopt($chCURLOPT_HTTPHEADER,
                                array('Authorization: Bearer '.$json->access_token));
                $result curl_exec($ch);
                $error curl_errno($ch);
                curl_close($ch);
                if ($error === 0) {
                        $json json_decode($result);
                        $countries array();
                        foreach ($json as $location) {
                                if ($location->placeType->name == 'Country') {
                                        $countries[$location->woeid] = $location->name;
                                }
                        }
                        asort($countries);
                }
        }

git "Permission denied (publickey,keyboard-interactive)."

If you are getting permission denied when working with git on a remote server using a key, this may help.

First test to ensure the key will be accepted by the remote server.


ssh -v git@git.example.com

Look for these lines in the output:

debug1: Next authentication method: publickey
debug1: Offering public key: /home/account/.ssh/example.key
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).

Then check your ~/.ssh/config file. Be sure the user is in the file and matches what worked with the ssh test.

~/.ssh/config

Code

Host git.example.com
    User git
    IdentityFile ~/.ssh/example.key

Now get back to work.

:)

:: Next >>