Skip to content

Instantly share code, notes, and snippets.

Learning Plan for Design Patterns and Principles of Good Design

These learning resources primarily focus on programming using Good Design Principles and Design Patterns

  • There is an emphasis on learning using PHP, although most patterns are universal to every object orientated language.

Learning Plan for Test Driven Development (TDD)

These learning resources primarily focus on Test Driven Development (TDD).

  • There is an emphasis on learning using PHP, Laravel and PHPUnit.
  • All these resources are free (at the time of writing)
<?php
class _╯°□°╯︵┻━┻ extends \Exception {}
function _╯°□°╯︵┻━┻($message) {
throw new _╯°□°╯︵┻━┻($message);
}
_╯°□°╯︵┻━┻("Flip Table");
@wzed
wzed / guzzle_pool_example.php
Created February 8, 2017 08:57
GuzzleHttp\Pool example: identifying responses to concurrent async requests
<?php
/*
* Using a key => value pair with the yield keyword is
* the cleanest method I could find to add identifiers or tags
* to asynchronous concurrent requests in Guzzle,
* so you can identify which response is from which request!
*/
$client = new GuzzleHttp\Client(['base_uri' => 'http://httpbin.org']);
@nikic
nikic / objects_arrays.md
Last active March 7, 2024 21:09
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

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:

@jpatters
jpatters / HeidiDecode.js
Last active March 20, 2024 14:29
Decodes a password from HeidiSQL. HeidiSQL passwords can be found in the registry. Use File -> Export Settings to dump all settings. Great for if you forget a password.
function heidiDecode(hex) {
var str = '';
var shift = parseInt(hex.substr(-1));
hex = hex.substr(0, hex.length - 1);
for (var i = 0; i < hex.length; i += 2)
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
return str;
}
document.write(heidiDecode('755A5A585C3D8141786B3C385E3A393'));
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
@jwarchol
jwarchol / README.md
Created July 28, 2012 21:06
Breathing LED on a Raspberry Pi

Raspberry Pi Breathing LED

This is a demonstration of using Ruby and the WiringPi Gem to pulse an LED connected to a GPIO pin in a manner similar to the sleep indicator on a MacBook.

A video of the effect can be found here: http://www.youtube.com/watch?v=NCUMXK7qf-c