Skip to content

Instantly share code, notes, and snippets.

View Kcko's full-sized avatar
🦜
fly like a bird ...

Roman Janko Kcko

🦜
fly like a bird ...
View GitHub Profile
@Kcko
Kcko / Open Graph Component.php
Last active August 29, 2015 14:05
Ukázková komponenta
<?
class OpenGraphControl extends Nette\Application\UI\Control
{
/** @var Nette\Utils\Html[] */
private $tags = [];
public function addOgTag($property, $content)
@Kcko
Kcko / download.php
Last active August 29, 2015 14:05
Download třída - pro starší projekty
<?php
/**
* trida pro stazeni souboru
* tato trida umoznuje stejnou funkcnost jak v IE tak ve firefoxu
*
* @author Dostal Ales
* @version 1.1
* @date 13.4.2006
*
@Kcko
Kcko / media-queries-respond.scss
Last active August 29, 2015 14:05
Respond mixin - MQ
/*
@author - Roman Janko, rjwebdesign.cz
@date - 28.8.2014
*/
@mixin respond($minWidth: false, $maxWidth: false) {
@if $minWidth and $maxWidth
{
@media screen and (min-width: $minWidth) and (max-width: $maxWidth) { @content; }
@Kcko
Kcko / Lat Lng.php
Last active August 29, 2015 14:05
Zjištění LAT / LNG souřadnic - Google maps
<?
function getLatLng($address)
{
$json = json_decode(file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false"));
$lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$lng = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
@Kcko
Kcko / Get location by Ip address.php
Last active August 29, 2015 14:05
Komplexní IP
<?
function getLocationInfoByIp(){
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = @$_SERVER['REMOTE_ADDR'];
$result = array('country'=>'', 'city'=>'');
if(filter_var($client, FILTER_VALIDATE_IP)){
$ip = $client;
}elseif(filter_var($forward, FILTER_VALIDATE_IP)){
@Kcko
Kcko / Headers ajax request - no JSONP.php
Last active August 29, 2015 14:05
JSONP - hlavičky
<?
header("content-type:text/html; charset=utf-8");
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Max-Age: 1000');
@Kcko
Kcko / ImageResponse.php
Last active August 29, 2015 14:05 — forked from matej21/ImageResponse.php
Image response - generování obrázků
<?php
class ImageResponse extends \Nette\Object implements \Nette\Application\IResponse
{
/** @var \Nette\Image|string */
private $image;
/**
* @param \Nette\Image|string
@Kcko
Kcko / Manuall form rendering
Last active August 29, 2015 14:05
Manuální renderování chyb -- inline
{form $form}
<ul class=error n:if="$form->ownErrors">
<li n:foreach="$form->ownErrors as $error">{$error}</li>
</ul>
<table>
<tr n:foreach="$form->controls as $input" n:class="$input->required ? required">
<th>{label $input /}</th>
<td>{input $input} <span class=error n:ifcontent>{$input->error}</span></td>
</tr>
@Kcko
Kcko / AntispamControl.php
Last active December 26, 2020 18:03
Nette antispam control
<?php
use Nette\Forms\Controls\TextInput,
Nette\Forms\Form,
Nette\Utils\Html;
/**
* AntispamControl
@Kcko
Kcko / Local redirect to develop server (images)
Last active August 29, 2015 14:06
Přesmerování z lokální na dev - obrázky
RewriteCond %{REQUEST_URI} ^/storage/images/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://domena/$1 [R=301,QSA]