Skip to content

Instantly share code, notes, and snippets.

@ciaranmcnulty
ciaranmcnulty / notes.md
Last active March 25, 2024 06:36
Notes on using Docker on ARM Macs (November 2021)

Docker for Mac

On M1 machines, Docker for Mac is running a lightweight linux ARM VM, then running containers within that, so containers are essentially running natively. Don't be fooled by the fact the UI or binary CLI tools (e.g. docker) might require Rosetta.

Within that VM is an emulation layer called QEmu. This can be used by docker to run Intel containers. This does not use Rosetta at all, and has a roughly 5-6X performance penalty. (If you just upgraded your CPU this may result in a similar performance to your old machine!)

Pulling and running with Docker

Many images in public registries are multi-architecture. For instance at the time of writing on Docker Hub the php:8.0-cli image has the following digests:

@imjasonh
imjasonh / markdown.css
Last active February 12, 2024 17:18
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@varas
varas / PhpUnit PsyShell debug
Created April 8, 2014 15:15
Catch PhpUnit assert errors with PsyShell REPL for live debugging
testX()
{
try {
...
} catch(\Exception $e) {
if (get_class($e) != 'PHPUnit_Framework_ExpectationFailedException')
Psy\Shell::debug(array('v' => get_defined_vars()));
throw($e);
}
}
@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:

@Seldaek
Seldaek / composer.json
Created February 19, 2013 15:55
security checker integration
{
// ...
"scripts": {
"post-update-cmd": [
"checker security:check composer.lock"
]
}
}
@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.
@javiereguiluz
javiereguiluz / WallpaperNotifier.php
Created April 17, 2012 09:15
The winner proposal of the Sismo Challenge programming contest
<?php
namespace Sismo\Contrib;
use Sismo\Notifier\Notifier;
use Sismo\Commit;
/**
* Notifies builds via the wallpaper (Mac only).
*
@p01
p01 / LICENSE.txt
Last active March 9, 2024 13:40 — forked from 140bytes/LICENSE.txt
Sudoku Solver in 140bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri - http://www.p01.org/releases/
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@j0k3r
j0k3r / Utils.class.php
Created July 19, 2011 10:31
well well well
<?php
public static function hideInProd(){
if(sfConfig::get('sf_environment') == 'prod'){
return " style=\"display:none;\"";
}
}
@mmacia
mmacia / in_memory_files.php
Created July 6, 2011 07:16
Generate files in-memory with PHP
<?php
/**
* This snippet shows a PHP neat trick: build a file into memory without use the filesystem.
*/
$fp = fopen('php://memory', 'rw'); // open an in-memory handler
for ($i = 0; $i < 100; ++$i) { // write some data to handler
fwrite($fp, $i."\n");