Skip to content

Instantly share code, notes, and snippets.

View tomasfejfar's full-sized avatar
🏠
Working from home

Tomáš Fejfar tomasfejfar

🏠
Working from home
View GitHub Profile
@tomasfejfar
tomasfejfar / sendmail.bat
Last active December 1, 2022 22:42
Windows fake sendmail to save mail to file
@echo off
::where do we store the messages
SET mailpath=c:\xampp\tmp\mail\
if not exist %mailpath% mkdir %mailpath%
::create filename
echo %date:~0,11%
SET filename=%date:~11,4%-%date:~7,2%-%date:~3,2%_%hours%-%time:~3,2%-%time:~6,2%_%time:~9,2%
@tomasfejfar
tomasfejfar / docker-compose.yml
Created April 3, 2018 11:35
Using YAML to reuse parts of existing docker-compose configuration
version: "3"
services:
apache: &apacheConfig
build: .
volumes:
- ./:/var/www/html:cached
- ./docker/php-apache/php.ini:/usr/local/etc/php/php.ini
- ./docker/php-apache/ssl-local:/etc/httpd/ssl
working_dir: /var/www/html
ports:
@tomasfejfar
tomasfejfar / php.ini
Created June 1, 2016 13:12
Settings to copy to your php.ini to make debugger work. It lists many unnecessary values just in case they were overridden before.
; path to your php_xdebug extension file
; download from https://xdebug.org/wizard.php
zend_extension="c:\xampp-php7\php\ext\php_xdebug-2.4.0-7.0-vc14.dll"
; disables profiler globally
xdebug.profiler_enable = 0
; allows enabling it selectively with request parameter "XDEBUG_PROFILE"
xdebug.profiler_enable_trigger = 1
; directory to output profiler files to
xdebug.profiler_output_dir = "C:\xampp-php7\tmp"
; profiler file name (with request uri and timestamp)
@tomasfejfar
tomasfejfar / gist:c3ac0d795dfadb13b7ef813d3e9410d3
Last active March 14, 2021 16:14
WSL2 docker setup for Windows
# based on https://susi.dev/dev-env-2020#5-use-systemd-hack-to-use-snap-optional-be-careful
# in windows
& 'C:\Program Files\VcXsrv\vcxsrv.exe' :0 -multiwindow -wgl -ac -silent-dup-error
# add firewall rule
netsh advfirewall firewall add rule name="XServer" dir=in program="C:\program files\vcxsrv\vcxsrv.exe" protocol=TCP localport=6000 action=allow profile=private remoteip=localsubnet
# in ubuntu
sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
<?php
/* my day code */
foreach ($minuteOfMyLife as $now => $whereAmI) {
if ($whereAmI == 'atHome') {
look_after_Honza();
} elseif ($whereAmI == 'atWork') {
code();
} else {
ride_my_bike();
}
<?php
$tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]);
if ($tables_views && !$error && !$_POST["search"]) {
$result = true;
$message = "";
if ($jush == "sql" && $_POST["tables"] && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) {
queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once
}
@tomasfejfar
tomasfejfar / rebase-to-moved.sh
Last active July 29, 2019 07:51
"rebase" onto codebase that moved to different directory
#! /bin/bash
# usage: rebase-to-moved.sh my-branch
# will create tag backup of current branch and rebase it on a moved directory
if [ -n "$(git status --porcelain)" ]; then
echo "You need to have clean working copy"
exit 1
fi;
git checkout $1
@tomasfejfar
tomasfejfar / register-phpstorm-folder.reg
Created March 18, 2019 13:43
Register PhpStorm in context menu of directory
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\PHP Storm]
@="Open in &PHP Storm"
"icon"="\"C:\\bin\\PhpStorm.cmd\""
[HKEY_CLASSES_ROOT\Directory\shell\PHP Storm\command]
@="\"C:\\bin\\PhpStorm.cmd\" \"%1\""
@tomasfejfar
tomasfejfar / gist:5c92333b60143f189a69e8a9cde55811
Created May 29, 2017 19:44
Convert PDF to text file using tesseract and imagemagick in cygwin
Required cygwin packages:
* tesseract-ocr
* ghostscript
* imagemagick
usr/bin/convert.exe -density 400 input.pdf -depth 8 output.tiff
tesseract -l eng -psm 1 output.tiff output_textfile
@tomasfejfar
tomasfejfar / composer.json
Created May 10, 2018 14:34
Local composer package
{
"repositories": [
{
"type": "path",
"url": "/path/to/project"
}
],
}