Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@hrach
hrach / api.php
Created March 21, 2013 22:09
Premyslim nad novym api pro Nette\Database. - je treba osekat aktualni selection, ktera ma metody delete, insert, atp. - je treba osekat metody save, update, delete na active row V nize draft api je toto odstraneno. Je zavedena repository. Programator by samozrejme mohl definovat vlastni repository. Co rikate na navrhovany smer? Jinak, aby bylo …
<?php
$user = $connection->repository('user')->get(1);
// $user instanceof Row
$users = $connection->repository('user')->query()->where('id in ?', [1, 2, 3]);
// $users instanceof SqlBuilder
$users = $connection->repository('user')->query()->where('id in ?', [1, 2, 3])->getSelection();
// $users instanceof Selection
<?php
class TestIterator implements \IteratorAggregate
{
public function getIterator()
{
return new ArrayIterator(array(1, 2, 3));
}
}
@hrach
hrach / FormMacros.php
Created July 29, 2013 13:44
FormMacros customization of Bootstrap3 macro (for Nette framework). See https://github.com/nextras/forms
<?php
/**
* signaly.cz - christian community platform
* MIT license
*
* @link https://www.signaly.cz
*/
namespace Signaly;
@hrach
hrach / benchmark.php
Created August 23, 2013 18:22
Objekty s preddefinovanymi property jsou pro Entity o polovinu datove narocne nez jedno pole + __get & __set. Objekt si totiz nemusi drzet klic.
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<?php
function calculate_median($arr) {
sort($arr);
$count = count($arr); //total numbers in array
$middleval = floor(($count-1)/2); // find the middle value, or the lowest middle value
if($count % 2) { // odd number, middle is the median
$median = $arr[$middleval];
} else { // even number, calculate avg of 2 medians
<?php
namespace model;
use DateTime;
use Nextras\Orm\Entity\Entity;
/**
* @property Salary[] $salaries {1:m SalariesRepository $employee}
@hrach
hrach / bar.php
Created October 13, 2013 09:24
Kviz: funkce registrovana autoloadem dostane jako parametr a) "Foo" b) "foo"
namespace test;
use Foo;
$foo = new foo();

Git push deploy

Requires installed gitolite in /home/git and following directory structure

/var
    /www
        /apps
        /hosts

/libs

@hrach
hrach / 0_reuse_code.js
Created January 23, 2014 10:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hrach
hrach / css_resources.md
Created January 23, 2014 10:04 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@hrach
hrach / python_resources.md
Created January 23, 2014 10:04 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides