Backstory: I decided to crowdsource static site generator recommendations, so the following are actual real world suggested-to-me results. I then took those and sorted them by language/server and, just for a decent relative metric, their Github Watcher count. If you want a heap of other projects (including other languages like Haskell and Python) Nanoc has the mother of all site generator lists. If you recommend another one, by all means add a comment.
<?php | |
/** | |
* Application driver class to initialize Phalcon and | |
* other resources. | |
*/ | |
class Application extends \Phalcon\Mvc\Application | |
{ | |
private static $mode = 'development'; // TODO change default to production | |
private static $modules = array( | |
'portal' => array( |
----- Esc ----- | |
Quick change directory: Esc + c | |
Quick change directory history: Esc + c and then Esc + h | |
Quick change directory previous entry: Esc + c and then Esc + p | |
Command line history: Esc + h | |
Command line previous command: Esc + p | |
View change: Esc + t (each time you do this shortcut a new directory view will appear) | |
Print current working directory in command line: Esc + a | |
Switch between background command line and MC: Ctrl + o | |
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name |
<?php | |
function validEmail($email) { | |
$isValid = true; | |
$atIndex = strrpos($email, "@"); | |
if (is_bool($atIndex) && !$atIndex) { | |
$isValid = false; | |
} else { | |
$domain = substr($email, $atIndex+1); | |
$local = substr($email, 0, $atIndex); | |
$localLen = strlen($local); |
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:
/*DISPLAY HINTS FOR INPUTS*/ | |
$("input").live("focus",function(){ | |
var hint = $(this).attr("hint"); | |
if(hint!==undefined && $(this).attr('hint')!= "oms.localized.hint."+$(this).attr('name')){ | |
$(this).after("<div class='hint'>"+hint+"</div>"); | |
$(".hint").fadeIn("fast"); | |
$(this).closest(".row").find("label.error").hide(); | |
} | |
}) |
@foreach(array_chunk($posts, 3) as $postSet) | |
<div class="row"> <!-- this div will surround every three posts --> | |
@foreach($postSet as $post) | |
<h3>{{ $post['title'] }}</h3> | |
@endforeach | |
</div> | |
@endforeach |
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32 | |
global start | |
section .text | |
start: | |
push dword msg.len | |
push dword msg | |
push dword 1 | |
mov eax, 4 |
I was asked how I deal with validation / create and update validation rulesets. Well here is one method I have used. Don't be afraid to build on top of what the framework has already given you. In my projects I use a base class for almost anything. You never know when you want your classes to inherit some common functionality. My BaseValidator
actually has some pretty useful methods and properties in it.
<?php
namespace FooProject\Internal\Validators;
use FooProject\Internal\Sanitizers\BaseSanitizer;
Here's the base sanitizer:
<?php
namespace FooProject\Internal\Sanitizers;
abstract class BaseSanitizer
{
/**