Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@MartinMajor
MartinMajor / DatabaseDeployPresenter.php
Created July 24, 2013 12:47
Tools for database versioning. For more informations see: http://www.youtube.com/watch?v=KTmlw5AKM8E (in CZ). - database.sql script is written for PostgreSQL - DatabaseDeployPresenter.php script is a snippet from Nette presenter - post-checkout is Git hook, that calls shell script that just runs your Nette presenter
/**
* Startup
*/
public function startup()
{
parent::startup();
// plain text output when http request
$this->getHttpResponse()->setContentType('text/plain');
@dg
dg / output detector.php
Created June 20, 2013 18:59
How can I find out where my output started?
<?php
ob_start(function($s, $flag) {
if ($flag & PHP_OUTPUT_HANDLER_START) {
$e = new \Exception;
$s = nl2br("Output started here:\n{$e->getTraceAsString()}\n\n") . $s;
}
return $s;
}, 2);
@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
@lichtner
lichtner / Article.php
Created November 6, 2012 11:03
Redactor.js nette presenter integration
<?php
class Article extends Base {
function getUploadDir() {
# e.g. something like this
return "upload/articles/article-$this[id]";
}
}
@vvondra
vvondra / GitBranchPanel.php
Created September 5, 2012 21:27
Git branch Nette debugger panel
<?php
namespace Vondra;
class GitBranchPanel implements \Nette\Diagnostics\IBarPanel
{
public function getPanel()
{
return '';
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active June 14, 2024 06:59
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@JanTvrdik
JanTvrdik / add_pull_request_to_issue_github.sh
Last active June 6, 2016 19:25
Add pull request to existing issue on github
#!/bin/bash
current_branch="$(git symbolic-ref HEAD 2>/dev/null)" || current_branch="(unknown)"
current_branch=${current_branch##refs/heads/}
github_username="JanTvrdik"
github_token="..."
if [[ $current_branch = "(unknown)" ]]
then
@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(
@fprochazka
fprochazka / explained.md
Created February 20, 2012 15:59
Useful git hooks for Gitolite

Git push deploy

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

/var
    /www
        /apps
        /hosts

/libs

@phpdude
phpdude / nginx.conf
Last active February 28, 2024 04:36
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;