Suppose you're opening an issue and there's a lot noisey logs that may be useful.
Rather than wrecking readability, wrap it in a <details>
tag!
<details>
Summary Goes Here
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
In the comments from my last post and on Twitter I noticed a lot of people who had something to say about PHP. The comments were varied but they usally sounded something like this (sorry @ipetepete, I picked yours because it was the shortest).
...the little bits of soul from all of us who've had to work on, and or maintain large PHP applications. – ipetepete
In Pete's defense, he did go on to say that rest of the stack I was using was a "smorgasbord of awesome". Thanks, Pete. I agree!
I would, however, like to take a little time to correct a misperception in the developer community about PHP. I recently got into this same... discussion... with Jeff Atwood, and I seem to be running into it more and more. So here goes. Please bear with me as I cover a little history further on.
Pete, and everybody else, _you're exactly rig
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:
Sirs, Gentlemen and Scholars,
I am appreciative of all of the discussion that has happened on the mysql_deprecation RFC (https://wiki.php.net/rfc/mysql_deprecation). It has helped me understand how we feel collectively about ext/mysql and how to deprecate it. I believe that clarifying what the term 'deprecation' means could help everyone to understand what we are trying to accomplish.
To quote wikipedia on the word 'deprecation':
In the process of authoring computer software, its standards or documentation, or other technical standards, deprecation is a status applied to features, characteristics, or practices to indicate that they should be avoided, typically because they have been superseded.
I think we all agree that ext/mysql should be avoided and that it has been superseded. What I want to point out is that deprecation is a process. The real question is: have we taken the proper steps in that process?
<!-- | |
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░ | |
░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░░░░░░░░░░░░░░░░░░░░░ | |
░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░░░░░░░░░░░░░░░░░░░░░ | |
░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░░░░░░░░░░░░░░░░░░░░░ | |
░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░░░░░░░░░░░░░░░░░░░░░ | |
█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█░░░░░░░░░░░░░░░░░░░░ | |
█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█░░░░░░░░░░░░░░░░░░░░ | |
░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░░░░░░░░░░░░░░░░░░░░░ |
# Export Active Record model as a CSV file | |
# | |
def self.render_csv active_record_model | |
CSV.generate do |csv| | |
csv << active_record_model.column_names | |
active_record_model.all.each do |m| | |
values = active_record_model.column_names.map{ |f| m.send f.to_sym } | |
csv << values | |
end | |
end |
<?php | |
// Displays all array indices and object properties | |
ini_set('xdebug.var_display_max_children', -1); | |
// Displays all string data dumped | |
ini_set('xdebug.var_display_max_data', -1); | |
// Controls nested level displayed, maximum is 1023 | |
ini_set('xdebug.var_display_max_depth', -1); |