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 / 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 / composer.json
Created May 10, 2018 14:34
Local composer package
{
"repositories": [
{
"type": "path",
"url": "/path/to/project"
}
],
}
@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 / 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
λ make serve
make[1]: Entering directory `W:/www/projects/flexproject'
/usr/bin/sh: make: command not found
make[1]: *** [serve_as_sf] Error 127
make[1]: Leaving directory `W:/www/projects/flexproject'
make: *** [serve] Error 2
@tomasfejfar
tomasfejfar / page-A4.css
Last active August 5, 2017 11:06
Style to create a page-like div with the exact measurements of A4 paper
@media screen {
.page {
background: white;
width: 18cm;
height: 27.7cm;
display: block;
margin: 0 auto;
margin-bottom: 0.5cm;
box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
padding: 1cm 1.5cm;