<?php // tests/HamcrestTestCase.php
namespace Tests;
use Hamcrest\MatcherAssert;
use Hamcrest\Util;
# Add this to file in home folder | |
"~/bin/layout-switch.sh" | |
Alt + Shift_L |
The PATH
is an important concept when working on the command line. It's a list
of directories that tell your operating system where to look for programs, so
that you can just write script
instead of /home/me/bin/script
or
C:\Users\Me\bin\script
. But different operating systems have different ways to
add a new directory to it:
- The first step depends which version of Windows you're using:
- If you're using Windows 8 or 10, press the Windows key, then search for and
"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."
Advantages of Exceptions
Excellent example of separating error-handling code from program logic
Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.
class Well | |
attr_accessor :next_well, :seeds, :owner | |
def initialize anOwner | |
self.seeds = 0 | |
self.owner = anOwner | |
end | |
def sow | |
current_seeds = self.seeds |
SELECT p.id, name, LENGTH(body) AS len | |
FROM ( | |
SELECT id | |
FROM projects | |
ORDER BY id | |
LIMIT 150000, 10 | |
) o | |
JOIN projects p | |
ON p.id = o.id | |
ORDER BY p.id |
[alias] | |
co = checkout | |
cob = checkout -b | |
coo = !git fetch && git checkout | |
br = branch | |
brd = branch -d | |
brD = branch -D | |
merged = branch --merged | |
st = status | |
aa = add -A . |
<?php | |
function resizeImage($source, $dest, $new_width, $new_height, $quality) | |
{ | |
// Taken from http://salman-w.blogspot.com/2009/04/crop-to-fit-image-using-aspphp.html | |
$image = new Phalcon\Image\Adapter\GD($source); | |
$source_height = $image->getHeight(); | |
$source_width = $image->getWidth(); | |
$source_aspect_ratio = $source_width / $source_height; | |
$desired_aspect_ratio = $new_width / $new_height; | |
if ($source_aspect_ratio > $desired_aspect_ratio) { |
This gist is about:
- https://twitter.com/taylorotwell/status/600680897550098432
- https://twitter.com/Ocramius/status/600705252539691008
Mainly:
function
cannot (should not) be used when side-effects occur