Skip to content

Instantly share code, notes, and snippets.

@feketegy
feketegy / mockmetrics.go
Created March 9, 2020 13:05
Mockmetrics Spy initial draft
// Package mockmetrics will gather metrics on a mocked function, such as number of calls, record arguments that the
// mocked function is called with.
//
// Example:
//
// type NumberGetter interface {
// GetNumber() int
// AddNumber(num int)
// }
//
@feketegy
feketegy / signal.go
Last active September 2, 2023 02:28
Go API server shutdown with graceful timeout
// Setup signal capture
signalShutdown := make(chan os.Signal, 1)
signal.Notify(signalShutdown, os.Interrupt, os.Kill, syscall.SIGTERM)
ctxCancel, cancel := context.WithCancel(context.Background())
wg := sync.WaitGroup{}
// Init API server
apiSrv := apiserver.New(ctxCancel, &wg)
@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;
}
@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 / 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 / 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 / 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;
{
"log": {
"version": "1.1",
"creator": {
"name": "Firebug",
"version": "2.0"
},
"browser": {
"name": "Firefox",
"version": "32.0.3"
$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);

Kohana 3.4

Features

Fixes

Improvements

  • Database should support Mysqli
  • Namespaces
  • Full PSR-0, PSR-4 support by default