A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$
if your browser aliases it:
~ 108 byte version
/* | |
* Contenteditable placeholder | |
* ----------------------------------- | |
* Emulates the behavior of the standerd implementation | |
* of the input placeholder="text", but can be used on any | |
* html element that supports focus. | |
* http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus | |
*/ | |
[contenteditable="true"]:before { |
<?php | |
function debug($data) { | |
$bt = debug_backtrace(); | |
$bt = array_shift($bt); | |
$data = print_r($data, true); | |
$html = <<<HTML | |
<div class="debug-output"> | |
%s |
{ | |
"CATALOG": { | |
"CD": [ | |
{ | |
"TITLE": "Empire Burlesque", | |
"ARTIST": "Bob Dylan", | |
"COUNTRY": "USA", | |
"COMPANY": "Columbia", | |
"PRICE": "10.90", | |
"YEAR": "1985" |
/* | |
* Flyspeck is Dependency Injection Container. | |
* | |
* Copyright (c) 2014 Anton Medvedev | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is furnished |
# Base editorconfig for new projects | |
root = true | |
[*] | |
end_of_line = lf | |
indent_style = space | |
tab_width = 4 | |
charset = utf-8 | |
trim_trailing_whitespace = true |
<?php | |
/** | |
* Custom redis client class to be able to set a custom prefix for every key | |
* | |
* @see https://github.com/nicolasff/phpredis | |
**/ | |
class RedisClient extends Redis { | |
/** | |
* Default prefix |
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't:
/** | |
* Create a web friendly URL slug from a string. | |
* | |
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support. | |
* | |
* Although supported, transliteration is discouraged because | |
* 1) most web browsers support UTF-8 characters in URLs | |
* 2) transliteration causes a loss of information | |
* | |
* @author Sean Murphy <[email protected]> |