Thursday 1 December 2016

Customising IntelliJ

Add item to external tools menu


To add an "Open Atom here" to the right click context menu follow these steps


  1. Open IntelliJ preferences
  2. Filter "external tools"
  3. Add new item
  4. Deselect Synchronise files after execution and Open console
  5. Add atom in the program field
  6. Add $FilePath$ in the Parameters field
  7. Add $ProjectFileDir$ in the Working directory field
  8. Check the dialog and click Ok

To add "Open Terminal here" do the same but at step 5 add "open" and step 6 add "$FileDir$ -a Terminal"






Add keymap to plugin  

To add a keymap to a plugin action follow these steps 
  1. Open IntelliJ preferences 
  2. Filter "keymap"
  3. Locate your plugin
  4. Add a keymap to the plugin action
As an example I've added F13 to IntelliVault Push to CRX 


Sunday 3 August 2014

Favicon, what you need to know in 2014

It's been a while since I looked into favicons, back in the day you could just pop one into the root of your domain and job done! So have things changed much?

Firstly, what exactly is an .ico file anyway?

The .ico file format is an image file format for computer icons originally in Microsoft Windows. An .ico file contains one or more small images at multiple sizes and color depths.

Where did it all begin?

Favicons were first supported in 1999, browsers look in the web root for a file called favicon.ico  Or it could be specified in another location using a link tag with the rel attribute having the value "shortcut icon"...
<link rel="shortcut icon"       
       href="http://mydomain.com/mypath/myicon.ico" /> 

The icons where primarily used for bookmarks by IE. 

The trouble with .ico files 

An .ico file typically contains multiple bitmap images, so is not really suited for web use where compressed file formats like .png are more suitable. (For a time, the MSN favicon used more bytes than the entire Google homepage, including the logo! [cite: ieinternals blogs.msdn.com])
Also, if a browser or device uses a specific icon, does it really want to download all the other versions as well, why not just download the relevant icon? And another thing, how do you tell what icons are contained within the .ico file, are they all correct, what if you need to add or edit one?

So what's the icon used for?

  • Bookmarks and history (original usage)
  • Browser tab and address bar
  • Speed dial
  • Desktop shortcuts
  • iOS/Android home screen icons
  • Windows task bar and Metro tile
  • Probably many others...
That’s a lot of use cases! In order to support most browsers and platforms, you need more than a dozen graphics. You'll need iOS icons with the rel attribute value "apple-touch-icon", browser icons with the rel value "icon" (not "shortcut icon") and the MS tiles meta tag name msapplication-TileImage...
iOS..
    <link href="/..." rel="apple-touch-icon" sizes="WxH" />

Web browsers etc...
    <link href="/..." rel="icon" sizes="WxH" type="..." />

MS ties...
    <meta name="msapplication-TileImage" content="/..." />

Altogether, you might need something like the following, depending on what versions of iOS you want to support...
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
<link rel="icon" type="image/png" href="/favicon-196x196.png" sizes="196x196">
<link rel="icon" type="image/png" href="/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">


To further complicate things IE11 will accept a browser configuration file specified by a meta tag named msapplication-config...
<meta name="msapplication-config" content="/ie-config.xml" />

You can put all the paths to all the the images and tile background colour, it might look something like this. 
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
   <msapplication>
     <tile>
        <square70x70logo src="small.png"/>
        <square150x150logo src="medium.png"/>
        <wide310x150logo src="wide.png"/>
        <square310x310logo src="large.png"/>
        <TileColor>#009900</TileColor>
     </tile>
     <badge />
     <notification />
   </msapplication>
</browserconfig>

So that's quite a lot of images, but at least they are compressed and separate so you can view them etc... so things are looking up.

Everything is a bed of roses... NOT!

Most modern browsers support a png favicon but…
  • Firefox and Safari will use the favicon that is listed last
  • Chrome for Mac will use whichever favicon is .ico formatted (if there is one), otherwise the 32×32 png
  • Chrome for Windows will use the favicon that comes first if it is 16×16, otherwise the will use the .ico file if there is one
  • If none of the aforementioned options are available, both Chromes will use whichever favicon comes first, exactly the opposite of Firefox and Safari
  • Chrome for Mac will ignore the 16×16 favicon and use the 32×32 version if only to scale it back down to 16×16 on non-retina devices
  • Opera, will choose from any of the available icons at complete random
  • IE no PNG support (but IE on Vista+ supports RGB/a PNGs inside ICO) caching nightmare!
[cite: jonathan tneal]

And what's worse is in FF and Chrome unneeded favicons are downloaded even though they aren't displayed or used anywhere. (FF bug-751721, Chrome bug-324820)

What to aim for, in short...

Have a favicon.ico in the root of the webapp, but don’t reference it with a <link ./> tag as this will cause a number of browsers to use it even when there is a better png alternative. You should still have the favicon.ico in the root directory as older browsers will request it by default and you don't want a load of 404s on your server.

Add link tags with rel="icon" sizes="width x height" for all sizes you want to support.

Create a browser config xml for IE11

Don't overdo it! Don't create 100's of png's as FF and Chrome will download them all regardless!


Further reading...




 


Wednesday 28 May 2014

Testing for variables in HTML on apache2


Note to self! You can use the expr to check for server variables, for example check for php...
<!--#if expr="$SERVER_SOFTWARE = /PHP/"-->
<!--#set var="usePHPincluds" value="true" -->
<!--#endif-->


Friday 10 January 2014

Showing hidden folders in Mac 10.9.1

To show hidden folders in finder, for me this worked...

defaults write com.apple.finder AppleShowAllFiles -boolean true

and to undo... 

defaults delete com.apple.finder AppleShowAllFiles

  • Open a terminal window and run...
  • defaults write com.apple.finder AppleShowAllFiles -boolean true
  • Now hold ‘alt’ on the keyboard and right click on the Finder icon and click on Relaunch (or run killall Finder in the terminal)

If that doesn't work try the above with... (undo with NO or FALSE respectively)

defaults write com.apple.Finder AppleShowAllFiles YES

or 

defaults write com.apple.Finder AppleShowAllFiles TRUE


Or if you just want to open a file, using the application's 'Open File' function (e.g. Sublime text 2). Press Command – Shift – [full stop] and all hidden files/folders will become visible, only in the Open File window, very handy!

Thursday 3 October 2013

Add 'Open command prompt here' option to Windows Server 2008


Add 'Open command prompt here' option to Windows Server 2008

Eeek, we need to dive into the registry for this!



1 Find the key:

HKEY_CLASSES_ROOT\Drive\shell\cmd

Rename the key Extended to Extende-Orig


2 Find the key:

HKEY_CLASSES_ROOT\Directory\shell\cmd

Rename the key Extended to Extende-Orig


That should work immediately.

Wednesday 17 July 2013

Mongo quick start

So I thought I'd jot down how to get started with MongoDB quickly so I don't have to look it all up again next time I have to install it.

These instructions are for mac, tweak as necessary!

Install it

In a terminal
brew update
brew install mongodb

Start it

Then open a terminal and start it
mongod

Open it

Open another terminal and open a mongo shell
mongo

Query it

You should now be in a mongo shell, to view dbs, collections etc... type
show dbs
use whicheverdbyouwant
db
show collections
To find out where the logs, db and config is type in...
db.getSiblingDB("admin").runCommand({getCmdLineOpts:1})
And for basic query, presuming you have a users collection, count all users starting with S
db.users.find( {"userName": /^S/ } ).count()

Find out more

All the above and much, much more... http://docs.mongodb.org/manual/contents/

Friday 24 May 2013

Unreadable gibberish

*
My biggest achievement this week was undoubtedly to convert a perfectly good webpage into gibberish!

Wb rukdist anwiinojort tcas hium mes etduentidfp te luqmibt e jenkuptyj waid cahbofu ubti godwerash!

The reason you might want to do this, is when you need to focus on some other aspect of the page/prototype/design other than the content. Or if you want to use screenshots but don't want potentially sensitive content to be visible.

This little method adds 'gibberish' to a context object e.g. window, then you can run gibberish.go( element ); where element is a dom node e.g. document.getElementsByTagName('body')[0] .

Check it out...
http://clanceyp.github.io/gibberish.js/
 

Note: the opinions on this page don't represent that of my employer in anyway. And, actually only vaguely represent my opinions on the date of publication. (Unlike Ms T, I am very much for turning)