Skip to content

Instantly share code, notes, and snippets.

View cakper's full-sized avatar
🎯
Focusing

Kacper Gunia cakper

🎯
Focusing
View GitHub Profile
@cakper
cakper / pre-commit.sh
Last active April 20, 2017 07:57
GIT pre-commit PHPSpec & PHP-CS-Fixer hook
#!/bin/sh
CWD=$(pwd)
STATUS=0
echo "Running PHPSpec and PHPCS"
if [ -f $CWD/bin/phpspec ]
then
$CWD/bin/phpspec run --quiet
<?php
namespace Dcwroc\TaskBundle\Entity;
class Task
{
private $name;
private $dueDate;
private $completed = false;
<?php
namespace Dcwroc\TaskBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
class Task
{
/**
* @Assert\NotBlank()
<?php
namespace Dcwroc\TaskBundle\InMemory;
use Dcwroc\TaskBundle\Entity\Task;
use Dcwroc\TaskBundle\Entity\TaskRepository;
class InMemoryTaskRepository implements TaskRepository
{
/**
@cakper
cakper / Board.swift
Last active September 15, 2017 11:49
Swift
protocol Board {
func isValidMove(move: (x: Int, y: Int)) -> Bool
}
### Keybase proof
I hereby claim:
* I am cakper on github.
* I am cakper (https://keybase.io/cakper) on keybase.
* I have a public key whose fingerprint is E49A 7AB1 A55F 7052 DA92 89B2 363A FBB6 6B77 9714
To claim this, I am signing this object:
@cakper
cakper / Statistics.swift
Created March 3, 2015 12:58
Statistics
class Statistics {
let minimum: Int
let maximum: Int
let average: Int
init(minimum: Int, maximum: Int, average: Int) {
self.minimum = minimum
self.maximum = maximum
self.average = average
}
@cakper
cakper / Palindrome.php
Last active August 29, 2015 14:18
Palindrome
<?php
class ListElement
{
/**
* @var ListElement
*/
private $next;
private $value;
trait CsvEncoder[A] {
def encode(value: A): List[String]
}
def createEncoder[A](func: A => List[String]): CsvEncoder[A] = {
new CsvEncoder[A] {
override def encode(value: A) = func(value)
}
}
implicit class TaskExtenstions[A](val task: Task[A]) extends AnyVal {
def timed(): Task[A] = {
for {
startTime <- Task.eval(nanoTime())
result <- task.doOnFinish {
case _ => logger.info(nanoTime() - startTime)
}
} yield result
}
}