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 / index.php
Last active November 16, 2016 10:05
Ošetření stránek pokud je vkládáme přímo z $_GET
<?php
// v $page může být cokoli, nejen "kontakt" nebo nic. Takže potřebujeme zkontrolovat, že nám tam nepropadne něco co nechceme.
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 'hlavni';
}
// uděláme pole se seznamem povolených hodnot
<?php
$pdoOptions = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
];
$pdo = new PDO('mysql:host=127.0.0.1;dbname=blog', 'root', '', $pdoOptions);
$statement = $pdo->prepare("SELECT * FROM posts");
$statement->execute();
$posts = $statement->fetchAll(PDO::FETCH_ASSOC);
@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 / DbTable.ft
Created October 28, 2016 20:13
Complex Velocity PhpStorm file template
#set($NameLenght = $NAME.length() - 5)
#set($ClassName = $NAME.substring(0, $NameLenght))
#set($TableName = $ClassName.toLowerCase())
#set($TablePrefix = $Namespace.toLowerCase())
#set($NAMESPACE = $Namespace)
#set($TYPE_TAG = '@var')
#set($TYPE_HINT = 'string')
<?php
namespace ${Namespace};
curl -L https://bootstrap.saltstack.com -o bootstrap_salt.sh
sudo sh bootstrap_salt.sh
echo "file_client: local" >> /etc/salt/minion
apt-get install python-git
apt-get install software-properties-common
@tomasfejfar
tomasfejfar / new_css_style.css
Created September 5, 2016 09:47
Simple theme to test why styles are not applied
body {
background-color: red !important;
}
@tomasfejfar
tomasfejfar / gist:e3607569e6a38424e7cf2d9d56187815
Created June 8, 2016 10:13
Minionless gitfs bug workaround that copies commented out formulas from minion settings to /srv/salt for local usage
#! /bin/bash
grep http /etc/salt/minion.d/settings.conf | cut -c6- | xargs -n1 git clone
find /home/tomas/ -type d -name "*formula" -exec git --git-dir={}/.git --work-tree={} pull origin master \;
find /home/tomas/ -type d -name "*formula" -exec sh -c "git --git-dir={}/.git --work-tree={} archive master | tar -x --strip-components 0 -C /srv/salt/" \;
@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 / .gitconfig
Created May 9, 2016 12:11
Command to create remote stash
[alias]
; creates timestamped branch rst-XXXXX and pushes it to default remote (origin)
rst = "!rst() { export tmpBranch=rst-$(date +%s) && git add -A && git checkout -b $tmpBranch && git commit -m 'WIP remote stash' && git push --set-upstream origin $tmpBranch; }; rst"
USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
elastics 20 0 9005m 2,6g 34m S 6,0 33,0 2779:33 java
logstash 39 19 1059m 409m 6332 S 3,9 5,1 3352:36 java
root 20 0 259m 41m 3392 S 0,1 0,5 4:51.60 salt-minion
root 20 0 737m 126m 3792 S 0,1 1,6 28:26.23 node