Skip to content

Instantly share code, notes, and snippets.

View podhy's full-sized avatar

Jakub Podhorský podhy

  • Freelancer
  • Jihlava, Czech republic
View GitHub Profile
@podhy
podhy / goje.c
Last active April 17, 2018 17:30
goje
#include <stdio.h>
#include <string.h>
#include <time.h>
#define MAX 8
char pole [MAX][MAX];
int poziceX=0, poziceY=0, trestnebody=10;
unsigned long cas1,cas2;
void inicializuj(){ //void je funkce, nema zadnou navratovou hodnotu, 'inicializuj' je nazev funkce,. () znaci ze to je funkce
@podhy
podhy / parallel.sh
Last active October 17, 2017 13:19
Psql parallel processing in Bash
#!/bin/bash
workers=4
STEP=$(psql -U svetluska -c "SELECT ceil(COUNT(*) / $workers) FROM svetluska.domination" -qtA svetluska)
time for ((i=0; i<$workers; i++))
do
echo "UPDATE svetluska.domination SET geometry = t.geometry_wkt FROM (SELECT id, geometry_wkt FROM svetluska.domination ORDER BY id LIMIT $STEP OFFSET $STEP*$i) t WHERE domination.id = t.id";
done | xargs -P $workers -I % psql -U svetluska -c "%" svetluska
#done | xargs -P 3 -I % echo %
@podhy
podhy / czkmoney.php
Created August 15, 2017 07:41
Doctrine CZK money type
<?php
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use Money\Currencies\ISOCurrencies;
use Money\Formatter\DecimalMoneyFormatter;
use Money\Money;
use Money\Parser\DecimalMoneyParser;
/**
@podhy
podhy / test_symfony_form_with_entity_types.php
Last active April 4, 2019 18:15
Demo of testing form type with multiple entity types
<?php
declare(strict_types = 1);
namespace Tests\CommissionsBundle\Form\Type;
use CommissionsBundle\DTO\CatalogItemGroupDTO;
use CommissionsBundle\Entity\CatalogItem;
use CommissionsBundle\Entity\CatalogItemGroup;
use CommissionsBundle\Form\Type\CatalogItemGroupType;
use Doctrine\Bundle\DoctrineBundle\Registry;
@podhy
podhy / presta_preklad.sql
Last active April 14, 2016 12:55
České překlady zemí do Prestashopu (data vytažena z číselníku zemí na ČSÚ). Soubor stačí spustit nad databází. Je potřeba mít v tabulce ps_lang češtinu.
create temporary table _zeme (id varchar(255) primary key, popis varchar(255));
insert into _zeme values ('AF', trim('Afghánistán '));
insert into _zeme values ('AX', trim('Alandy '));
insert into _zeme values ('AL', trim('Albánie '));
insert into _zeme values ('DZ', trim('Alžírsko '));
insert into _zeme values ('AS', trim('Americká Samoa '));
insert into _zeme values ('VI', trim('Americké Panenské ostrovy '));
insert into _zeme values ('AD', trim('Andorra '));
insert into _zeme values ('AO', trim('Angola '));
insert into _zeme values ('AI', trim('Anguilla '));
<?php
$join = [];
if ($something)
{
$join[] = "LEFT JOIN tabulka ON podminkaa = podminkab";
}
echo "SELECT * FROM product " . implode(" ", $join) . " WHERE active = ?";