Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Allaert patrickallaert

View GitHub Profile
@patrickallaert
patrickallaert / Xsetup
Created Nov 2, 2017
SDDM black screen gentoo
View Xsetup
# /usr/share/sddm/scripts/Xsetup
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --output eDP-1-1 --mode 2880x1620
View test.c
#include <bsd/string.h>
int main() {
char error[100];
char test[10];
test[0] = '\0';
strlcpy(error, test, sizeof(error));
return 0;
View sample.php
<?php
if (!is_callable($callable)) {
throw new \InvalidArgumentException(
'The controller for URI "' . $request->getPathInfo() . '" is not callable. '.
$this->getControllerError($callable)
);
}
View sprintf_vs_without.php
<?php
$distinct = "DISTINCT"; // or empty
$columns = "a, b, c"; // columns
$table = "thetable"; // table to retrieve content from
$delete = false; // Fetch records marked deleted
$conditions = ""; // Series of conditions
$orderCol = "a"; // Order by
$orderDir = "ASC"; // Order by ASC/DESC
$limit = ""; // Optional limit number
View poll.php
<?php
// Performance appart, what is the most *READABLE* code to generate a simple error string?
$errorMessage = "Rule execution failed: " . $e->getMessage(); // Choice 1
$errorMessage = "Rule execution failed: {$e->getMessage()}"; // Choice 2
$errorMessage = sprintf('Rule execution failed: %s', $e->getMessage()); // Choice 3
@patrickallaert
patrickallaert / FooBar.php
Created Feb 15, 2017
FooBar with full (and duplicated) comments
View FooBar.php
<?php
/**
* Class FooBar.
*/
class FooBar
{
/** @var Baz */
private $baz;
@patrickallaert
patrickallaert / FooBar.php
Created Feb 15, 2017
FooBar with minimal comments
View FooBar.php
<?php
class FooBar
{
/** @var Baz */
private $baz;
pulic function __construct(Baz $baz)
{
$this->baz = $baz;
@patrickallaert
patrickallaert / .gitconfig
Created Apr 13, 2016
My .gitconfig file ([alias] part)
View .gitconfig
[alias]
dic = diff --cached
prb = pull --rebase
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
sed = ! git grep -z --full-name -l '.' | xargs -0 sed -ri -e
wdiff = diff --color-words='[A-z0-9_-]+|[^[:space:]]'
hide = update-index --assume-unchanged
unhide = update-index --no-assume-unchanged
hidden = "!git ls-files -v | grep ^h | cut -c 3-"
@patrickallaert
patrickallaert / compareEnvironments.sh
Last active Dec 2, 2015
Utility to compare eZ Publish Content Types from multiple environments (e.g. dev / staging / production). -- https://twitter.com/patrick_allaert
View compareEnvironments.sh
vim -d \
<(echo 'CALL display_classes();' | mysql -h devHost database --skip_column_names) \
<(echo 'CALL display_classes();' | mysql -h stagingHost database --skip_column_names) \
<(echo 'CALL display_classes();' | mysql -h productionHost database --skip_column_names)
View queue-vs-stack.sh
echo SplStack
echo ========
echo php 5.5
echo -------
for i in $(seq 10); do
time php5.5 -d memory_limit=-1 -n spl-stack.php
done
echo php 5.6