Skip to content

Instantly share code, notes, and snippets.

View midorikocak's full-sized avatar
😎
cool

Midori Kocak midorikocak

😎
cool
  • Prague
View GitHub Profile
<?php
class Brainfuck
{
public $ref;
function &__get($x) {
$this->ref = new class($this->ref) {
private $p;
@midorikocak
midorikocak / slim1.php
Created June 6, 2016 10:33
Slim Example 1
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
@midorikocak
midorikocak / swagger-example.php
Created June 6, 2016 10:40
Swagger Editor Generated Slim
<?php
/**
* Swagger Petstore (Simple)
* @version 1.0.0
*/
require_once __DIR__ . '/vendor/autoload.php';
$app = new Slim\App();
@midorikocak
midorikocak / index.html
Created September 15, 2016 18:39
Html5 Example Semantic Layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Layout</title>
</head>
<body>
<header>
<h1>This is the Title of the Content</h1>
</header>
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}footer,nav{display:block}a{background-color:transparent}a:active,a:hover{outline:0}h1{font-size:2em;margin:.67em 0}button,input,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible;text-transform:none;-webkit-appearance:button;cursor:pointer}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}html,body{height:100%}html{box-sizing:border-box}*,:before,:after{-webkit-box-sizing:inherit;-moz-box-sizing:inherit;box-sizing:inherit}html,body{font-size:100%}body{background:#fff;color:#222;cursor:auto;font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif;font-style:normal;font-weight:400;line-height:1.5;margin:0;padding:0;position:relative}a:hover{cursor:pointer}.right{floa
@midorikocak
midorikocak / meal-form.html
Created January 16, 2017 11:15
A custom element example.
<!-- Defines element markup -->
<template>
<form>
<fieldset>
<label for="name">Name</label>
<input type="text" placeholder="Meal Name" id="name" name="name">
<label for="date">Date - Time</label>
<input type="date" placeholder="Set Date" id="date" name="date">
<input type="time" placeholder="Set Time" id="time" name="time">
<label for="calories">Calories</label>
@midorikocak
midorikocak / concepts.md
Last active February 21, 2017 15:14
Object Oriented Programming Concepts (Draft)

Kavramlar

Genel

  • Abstract Class
  • Abstraction (hiding details) (OK)
  • Aggregation (HAS-A) (OK)
  • Better Architecture (OK)
  • Class (OK)
  • Cleaner Code (OK)
  • Conceptualization (OK)
@midorikocak
midorikocak / array_filter_binary.php
Last active April 25, 2017 16:04
A php array filter function to filter arrays based on integer used as a binary map.
/*
* 5 or 0b101 should return $array[0] and $array[2]
* If array is bigger than 64 elements, filter will not work.
* consider dividing filter into array of 8 bit integers.
* Doesn't preserve keys.
*/
function filterArray($array, $integer){
$result = [];
$index = 0;
while($integer>0){
@midorikocak
midorikocak / hanoi.php
Created May 15, 2017 16:39
Towers Of Hanoi
<?php
$origin = [5,4,3,2,1];
$buffer = [];
$destination = [];
function moveDisks($number, array &$origin, array &$destination, array &$buffer)
{
echo "\n\n";
if($number <= 0) return;
@midorikocak
midorikocak / tail.php
Created June 20, 2017 13:34
Google Interview Question (Implement unix tail using file API)
<?php
function tail($filename, $numberOfLines){
$counter = 0;
$handler = fopen($filename, 'r');
$end = filesize($filename);
$start = -1;
$current = $start;