Skip to content

Instantly share code, notes, and snippets.

View hrach's full-sized avatar

Jan Škrášek hrach

View GitHub Profile
@skyfishjy
skyfishjy / CursorRecyclerViewAdapter.java
Last active March 18, 2025 21:07
CursorRecyclerViewAdapter
/*
* Copyright (C) 2014 skyfish.jy@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
<?php
use Nette\Application\UI\Presenter;
use Nette\DI\CompilerExtension;
/**
* Auto register presenters as services
* @author Martin Bažík <[email protected]>
@woxtu
woxtu / gist:c186b173be3a53171533
Last active March 4, 2019 05:37
Face detection in Rust
pub mod cv {
extern crate libc;
use self::libc::{c_char, c_double, c_int, c_schar, c_void};
#[repr(C)]
pub struct HaarClassifierCascade;
#[repr(C)]
pub struct MemStorage;
@hrach
hrach / nginx.conf
Created June 9, 2014 20:50
nginx + Nette framework rewrite
server {
listen 80;
server_name example.com;
root d:/webs/example.com/www;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
location ~ \.phpt?$ {
try_files $uri @missing;
@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 August 3, 2025 13:36
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