Skip to content

Instantly share code, notes, and snippets.

// --== GOOD ==--
class SomeClass
{
protected $_db = null;
public function __construct(Database $db)
{
$this->_db = $db;
}
@feketegy
feketegy / toc
Last active December 21, 2015 20:59
Kohana Documentation TOC
1 General
1.1. About Kohana [1 page]
- On this page we talk a little bit about kohana, what it stands for, etc.
- server requirements
- kohana license
- link to forum, irc channel, stackoverflow, etc.
1.2. Change Log [1 page]
- maybe a redmine dump with the latest bugfix, features, etc.

Kohana 3.4

Features

Fixes

Improvements

  • Database should support Mysqli
  • Namespaces
  • Full PSR-0, PSR-4 support by default
$png = [
'format' => 'H32',
'marker' => '89504e470d0a1a0a0000000d49484452'
];
$bytes_to_read = strlen( $png['marker'] ) / 2;
$fp = fopen('your-filename.png', 'r');
$data = fread($fp, $bytes_to_read);
fclose($fp);
{
"log": {
"version": "1.1",
"creator": {
"name": "Firebug",
"version": "2.0"
},
"browser": {
"name": "Firefox",
"version": "32.0.3"
@feketegy
feketegy / wtf.sql
Created February 2, 2016 21:24 — forked from Swader/wtf.sql
How would you rewrite this query to be MySQL 5.7 friendly? Currently fails due to new GROUP BY rules.
select extf.* from (
select ExternalTransactinId
from ebay_order_items
ExternalTransactionId is not null
group by ExternalTransactionID
) extf
extf.z_shipmentno is null
and extf.orderstatus = 'Completed'
and extf.timestamp > '2015-02-25'
order by extf.timestamp desc;
@feketegy
feketegy / psr7router.php
Created July 26, 2016 11:14
psr7 router example using league and diactronos
// Setup the router
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
// Init container and set PSR7 shareables
$routeContainer = new League\Container\Container;
// Set response type (must be psr7 response interface)
$routeContainer->share('response', Zend\Diactoros\Response::class);
@feketegy
feketegy / dependencyinjection.php
Created November 7, 2016 21:42
dependency injection
// DB Interface
interface DBInterface {
public function query( $myQuery );
}
// Database Dependency Class
class Database implements DBInterface
{
public function query( $myQuery ) {
return $myQuery;
@feketegy
feketegy / repo.php
Created November 11, 2016 14:39
MVC + Repository
<?php
class MyModel
{
public $id;
public $name;
public $date_of_birth;
public function getDateOfBirth()
{
@feketegy
feketegy / index.html
Last active November 17, 2017 10:00
d3 zoom pan problem
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
.container {
height: 700px;
border: 1px solid #ff0000;
}