Skip to content

Instantly share code, notes, and snippets.

View NBoulfroy's full-sized avatar
🎯
Focusing

Nicolas BOULFROY NBoulfroy

🎯
Focusing
View GitHub Profile
@maxpou
maxpou / _pagination.html.twig
Last active February 26, 2023 20:28
Example of pagination with Twig
{#
Parameters:
* nbPages (int): number of pages
* currentPage (int): current pages
* url (string): route name & query (string): route parameter
ex: list/page-5?q=myFilter (5 = page and query = myFilter)
#}
{% spaceless %}
{% if nbPages > 1 %}
@real34
real34 / memory_usage.php
Created November 1, 2011 06:59
PHP : A simple function to display the current memory usage
<?php
// @see http://fr2.php.net/manual/en/function.mb-convert-encoding.php#103300
function memory_usage() {
$mem_usage = memory_get_usage(true);
if ($mem_usage < 1024) {
$mem_usage .= ' bytes';
} elseif ($mem_usage < 1048576) {
$mem_usage = round($mem_usage/1024,2) . ' kilobytes';
} else {
$mem_usage = round($mem_usage/1048576,2) . ' megabytes';