Skip to content

Instantly share code, notes, and snippets.

View jaromirnyklicek's full-sized avatar

Jaromír Nyklíček jaromirnyklicek

View GitHub Profile
@jaromirnyklicek
jaromirnyklicek / BootstrapHorizontalFormRenderer.php
Created March 14, 2012 19:56
Changes Nette form default markup to be compatible with Bootstrap CSS framework.
<?php
namespace SmartCMS;
use Nette,
Nette\Utils\Html;
class BootstrapHorizontalFormRenderer extends Nette\Forms\Rendering\DefaultFormRenderer
{
public $wrappers = array(
@jaromirnyklicek
jaromirnyklicek / scroll.js
Created April 18, 2012 14:09
Scrollovani
function checkScroll($parent) {
if($parent.scrollBottom() == 300) {
$('#social').css(position: 'absolute');
} else {
$('#social').css(position: 'fixed');
}
}
$(document).ready(function() {
checkScroll($(this));
@jaromirnyklicek
jaromirnyklicek / php-xls.php
Created June 13, 2012 12:43
PHP -> XLS export
require_once dirname(__FILE__) . '/php-excel.class.php';
$visitors = $this->visitorModel->getAll();
$data = array();
foreach($visitors as $visitor) {
$row = array();
$row[] = $visitor->name;
$row[] = $visitor->surname;
$data[] = $row;
}
<?php
require_once dirname(__FILE__) . '/nette.min.php';
require_once dirname(__FILE__) . '/dibi.min.php';
if(!isset($_GET['lang'])) {
die('Do parametru adresy "lang" vloz zkratku pridavaneho jazyka.');
} else {
$lang = $_GET['lang'];
}
<?php
$row = $model->findName($name);
if($row === FALSE) {
// $name bylo nejake super exoticke, nemame ho v db
return 'Vážená/Vážený ' . $name;
} else {
if (count($row) == 1) {
// jmeno ma v db jenom jeden zaznam, napr. "Lukas";
<?php
class DbRoute extends Object implements IRouter
{
protected $absolute = FALSE;
public function __construct($absolute = FALSE)
{
$this->absolute = $absolute;
}
server {
error_log /var/log/nginx/skeletis-content.log;
rewrite_log on;
root /var/www/skeletis-content.cz;
index index.html;
server_name skeletis-content.cz skeletis-content.loc;
location ~* /(\d+)\.(jpg|jpeg|png|gif|bmp)/([a-z0-9]+)/(\d+)x(\d+) {
@jaromirnyklicek
jaromirnyklicek / App.js
Created July 13, 2017 12:45
React native app with navigation
import React from 'react';
import {StackNavigator} from "react-navigation";
import {AppRegistry, Button} from "react-native";
class MainScreen extends React.Component {
static navigationOptions = {
title: 'Main'
};
render() {
@jaromirnyklicek
jaromirnyklicek / MoveSubtree.php
Created August 29, 2017 21:53
Tree traversal - move subtree
<?php
public function moveSubtree($node, $parent)
{
$lft = $parent->getRgt();
$lvl = $parent->getLvl() + 1;
$diff = $node->getRgt() - $node->getLft() + 1;
if ($lft > $node->getLft()) {
curl --location --request POST 'api.plnapenezenka.cz/me/favorite-shops' \
--header 'Content-Type: application/json' \
--header 'Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIiwiY3JlYXRlZEF0IjoxNTgyMTA0MTgxfQ.eyJpc3MiOiJueWtsaWNla0BnbWFpbC5jb20iLCJhdWQiOiJwaGZ6dGw1NDMyNTE0MDkyNGNhNC4zNTgzNTM1MyIsImp0aSI6IjI4MTA3IiwiaWF0IjoxNTgyMTA0MTgxLCJleHAiOjE1ODIxMDc3ODEsInZhbGlkX2Zyb20iOiIyMDIwLTAyLTE5VDEwOjIzOjAxKzAxOjAwIiwiaXNzdWVkX2F0IjoiMjAyMC0wMi0xOVQxMDoyMzowMSswMTowMCIsInZhbGlkX3RvIjoiMjAyMC0wMi0xOVQxMToyMzowMSswMTowMCJ9.' \
--data-raw '{
"shopId": 2534
}'