Postgresql EESTERROR invalid byte sequence for encoding “UTF8”: 0xff

After Postgres update one of our php web gallery stopped working. Uploading of a photo ended with the following error: invalid byte sequence for encoding "UTF8": 0xff

For years we have allways put an ‘E’ before escaped image data in our INSERT queries.
pg_query("INSERT INTO gallery (name, data) VALUES ('My photo', E'$escaped_image')");

I found the solution in http://php.net/manual/en/function.pg-escape-bytea.php

// Escape image data
$escaped = pg_escape_bytea($data);

// The wrong code, which stopped working after Postgres update
pg_query("INSERT INTO gallery (name, data) VALUES ('Pine trees', E'$escaped')");

// The right code
pg_query("INSERT INTO gallery (name, data) VALUES ('Pine trees', '$escaped')");

CSS 100% width minus paddings, margins and border

img{
	width: 100%;
	background-color: #fff;
	box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.8);
	border: thin solid #ccc;
	padding: 10px;
}

The code above gives this result:
2014-07-17_css_box_model_no

As you can see, the 100% width plus 10px padding exceeds the actual available width, so here is the correct code how it should be:

img{
	-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
	-moz-box-sizing: border-box;    /* Firefox, other Gecko */
	box-sizing: border-box;         /* Opera/IE 8+ */
	width: 100%;
	background-color: #fff;
	box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.8);
	border: thin solid #ccc;
	padding: 10px;
}

2014-07-17_css_box_model_yes
In this example the image with its paddings, margins and border fits inside the available container and 100% is not exceeding it.

More on this topic: http://css-tricks.com/box-sizing/

Configure LightTable editor so it behaves more like SublimeText

In LightTable press Ctrl-Space to open Commands pane. Type “settings” and choose “Settings: User keymap”.
It will open keymap configuration. The following configuration adds PageUP and PageDown keyboard shortcuts to switch between opened files and Ctrl-/ shortcut to comment/uncomment current line.

;; User keymap
;; -----------------------------
;; Keymaps are stored as a set of diffs that are merged together together
;; to create the final set of keys. You can modify these diffs to either add
;; or subtract bindings.
;;
;; Like behaviors, keys are bound by tag. When objects with those tags are active
;; the key bindings are live. Keys can be bound to any number of Light Table commands,
;; allowing you the flexibility to execute multiple operations together. To see a list
;; of all the commands you can execute, start typing a word related to the thing you
;; want to do in between the square brackets (e.g. type "editor").

{:+ {:app {}

     :editor {"alt-w" [:editor.watch.watch-selection]
              "alt-shift-w" [:editor.watch.unwatch]
              "pmeta-/" [:toggle-comment-selection]}
     :tabs {"pmeta-pageup" [:tabs.prev]
            "pmeta-pagedown" [:tabs.next]
            }
     }}

To add line numbers or change color theme, you need to configure “User behaviors”. Press Ctrl-Space to open Commands pane, type “settings” and choose “Settings: User behaviors”.
Here is my configuration:

;; User behaviors
;; -----------------------------
;; Behaviors are stored as a set of diffs that are merged together
;; to create the final set of functionality that makes up Light Table. You can
;; modify these diffs to either add or subtract functionality.
;;
;; Behaviors are added to tags, objects with those tags then automatically gain
;; whatever logic the behavior imparts. To see a list of user-level behaviors,
;; start typing a word related to the functionality you want in between the square
;; brackets (e.g. "theme").

{:+ {
     ;; The app tag is kind of like global scope. You assign behaviors that affect
     ;; all of Light Table here
     :app [(:lt.objs.style/set-skin "dark")]

     ;; The editor tag is applied to all editors
     :editor [:lt.objs.editor/wrap
              :lt.objs.editor/line-numbers
              (:lt.objs.style/font-settings "" "12" "1.2")
              (:lt.objs.style/set-theme "monokai")]

     ;; Here we can add behaviors to just clojure editors
     :editor.clojure [(:lt.objs.langs.clj/print-length 1000)]}

 ;; You can use the subtract key to remove behavior that may get added by
 ;; another diff
 :- {:app []}}