Development Stickies

Development Notes for Web Programmers…

Google Chrome SLOW but fast in Incognito Window

Do you think your Google Chrome is very slow? Loading multiple images very slowly, one after the other?

Try incognito window: is it fast now?

Then this might solve your problem: Click on your name on the top right corner of Google Chrome, log out of Chrome itself (it will warn you to delete 1000s of items…).

Log out.

Log in again. It should be fast again.

Thanks Google.

Mac OSX Mavericks – Customize Terminal Prompt

I use bash and I prefer this config as prompt:

vi .bashrc

export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad
export GREP_OPTIONS='--color=auto'
export TERM="xterm-color"
PS1='\u\[\033[01;33m\]@\[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]'
export PS1

rsync Read/Write Errors or I/O errors – how do they appear in the output?

Ever wondered how read errors look like during an rsync process? You might want to search for them and for that you need to know how they look like.

Here is how they look like:

FIRST you get a WARNING, saying that there was a read error (can happen). rsync will try later again to copy that file:

fa/45/57-8413-4562-b673-34627fc111d1.pdf
WARNING: fa/45/57-8413-4562-b673-34627fc111d1.pdf failed verification -- update discarded (will try again).
rsync: read errors mapping "/home/myapplication/a0/fa/45/57-8413-4562-b673-34627fc111d1.pdf": Input/output error (5)

SECOND if the read error still occurs for that file, it writes an ERROR:

ea/7e/83-2c70-4d86-863d-33ca893bdab3-large.jpg
ERROR: ea/7e/83-2c70-4d86-863d-33ca893bdab3-large.jpg failed verification -- update discarded.
rsync: read errors mapping "/home/myapplication/a0/ea/7e/83-2c70-4d86-863d-33ca893bdab3-large.jpg": Input/output error (5)

CrashPlan on MacOS crashes all the time…

Are you using the nice backup software CrashPlan and you suddenly have the issue that it always crashes?

Are you backing up A LOT OF FILES ?

Then you have to increase the memory assignment for CrashPlan, here is how you do that:

1 — Stop the backup engine by typing this into the Terminal application:

sudo launchctl unload /Library/LaunchDaemons/com.crashplan.engine.plist

Note: This will prompt you for your system password, you will not get feedback as you type. Enter your password and press return.

2 — Run this command to edit the backup engine:

sudo nano /Library/LaunchDaemons/com.crashplan.engine.plist

3 — In /Library/LaunchDaemons/com.crashplan.engine.plist, find this line: -Xmx512m

Note: In order to navigate within the document, you will have to use the arrow keys on your keyboard to find the correct line.

4 — Edit that line to something larger such as 768, 1024 or 1536. E.g.: -Xmx4096m

This sets the maximum amount of memory that CrashPlan can use. CrashPlan will not use that much until it needs it. I would recommend starting out setting it to 2048, and go higher only if you continue experiencing problems. You can increase it above 2048 if you have a really large file-selection.

5 – Hold the Control key and tap the x key to exit. Choose “y” to confirm it.

6 – You’ll see the prompt “File Name to Write.” Hit enter to save to the existing location.

7 – Start the backup engine by typing:

sudo launchctl load /Library/LaunchDaemons/com.crashplan.engine.plist

Adobe Support Schweiz, Deutschland, Österreich

Manchmal hat man leider mit Adobe Produkten zu tun, und das nervt, v.a. dann wenn man den Support braucht, wenn zum Beispiel die Lizenz nicht aktiviert werden kann…

Weil man jedesmal mindestens 10 Klicks braucht, um die Support Nummer zu finden (vielen Dank Adobe), hier die Nummern im Klartext und hoffentlich indexiert das Google an oberster Stelle.

Adobe Support Telefonnummern:

Deutschland: 069 500 718 55
Österreich: 01795674844
Schweiz: 0448009581

My favorite special characters (unicode) for web pages

– and —

· (dot in the middle)

Great collection: http://copypastecharacter.com/

GMail Google Mail – How to search by size

Sometimes you want to cleanup your mail account at Google in order to safe space.

This is how you search for mails that are larger than 10MB and which are older than 1 year:

size:10m older_than:1y

Hope this helps!

crontab – Examples

Some examples for configuring cronjobs with crontab on Ubuntu:

# .-------------------- minute (0 - 59)
# |   .---------------- hour (0 - 23)
# |   |   .------------ day of month (1 - 31)
# |   |   |   .-------- month (1 - 12 or Jan-Dec)
# |   |   |   |   .---- day of week (0 - 6)
# |   |   |   |   |     where sunday=0 or 7
# |   |   |   |   |     OR put sun,mon,tue,wed,thu,fri,sat
# |   |   |   |   |
# *   *   *   *   *     command to be executed

# every minute
*/1   *   *   *   *     /home/myuser/script.sh

# every hour
0     */1 *   *   *     /home/myuser/script.sh

# every three hours
0     */3 *   *   *     /home/myuser/script.sh

# every minute at specific seconds, execute TWO SCRIPTS
0,13,31,47  * * * *     /home/myuser/script.sh , /home/myuser/script2.sh

Visual crontab editor:
http://www.corntab.com/

WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

Did you just have this error message? Do you want to reuse an existing Node/Element from one DOM document in another one? Me too. And this is how you can copy paste elements from one doc into the other one:

Just appending does not work, you have to import and append it:

Element toCopy = ... // somehow you get the element from the source doc
Element imported = (Element)documentForXSLT.importNode(toCopy, Boolean.TRUE);
targetDoc.getDocumentElement().appendChild(imported);

That’s all the magic.

If you skip the second line you will get the error.

How to absolutely control the caching in browsers

Issue

There are many ways how to control caching:

  • you can use parameters in your page headers (examples)
  • you can use parameters in the HTTP response (Last-Modified, Expires, see all of them)

After testing all options with different browsers, it’s a nightmare.
What I needed was a solid mechanism how to really make sure that the browser loads the updated static file!

This is how you can do it:

You reference your static files with a parameter in the URL which you change when you want the browsers to update the cache!

Examples:
<script type="text/javascript" src="/app/js/main.js?v=2"></script></pre>
<link href="/app/css/jquery-ui-1.8.14.custom.css?v=7" type="text/css" rel="stylesheet" />

The most elegant way is to dynamically insert the release number of your software deployment. This way you don’t even have to think about this issue anymore:

<script type="text/javascript" src="/app/js/main.js?v={$version}"></script></pre>
<link href="/app/css/jquery-ui-1.8.14.custom.css?v={$version}" type="text/css" rel="stylesheet" />