Skip to content

Instantly share code, notes, and snippets.

Avatar
👻

Matteo Giachino matteosister

👻
View GitHub Profile
@matteosister
matteosister / OptionRepositoryTrait.php
Last active Aug 29, 2015
A trait to use the PhpOption in the EntityRepository
View OptionRepositoryTrait.php
<?php
namespace Vendor\Repository;
use PhpOption\Option;
use Doctrine\DBAL\LockMode;
trait OptionRepositoryTrait
{
public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
View gist:17c1ec8bc2b391ae5def
server {
server_name www.hostname.com;
root /var/www/hostname/current/web;
listen 81 default_server;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
View function_composition.hs
even :: Int -> Bool
not :: Bool -> Bool
isnoteven :: Int -> Bool
isnoteven = not . even
even(10) -- True
not(True) -- False
isnoteven(9) -- True
View simple_function_composition.exs
defmodule SimpleFC do
require Integer
def even(n), do: Integer.is_even(n)
def negate(n), do: not n
def compose(func1, func2) do
fn (n) ->
func2.(func1.(n))
end
View infix_operator.ex
defmodule InfixFC do
@doc """
define an infix operator <|> to compose functions
"""
defmacro left <|> right do
quote bind_quoted: [left: left, right: right] do
fn (v) -> left.(right.(v)) end
end
end
View function_composition.exs
defmodule PipeFunctionComposition do
require Integer
def even(n), do: Integer.is_even(n)
def negate(n), do: not n
def multiply_by(n, factor), do: n * factor
@doc """
true if the passed number is not even
"""
View infix_use.ex
defmodule TestInfix do
import InfixFC
def invert(what) do
what |> String.graphemes |> Enum.reverse |> Enum.join
end
def inverted_and_stripped_upcase(subject) do
func = (&invert/1) <|> (&String.upcase/1) <|> (&String.strip/1)
func.(subject)
View gist:3794247
Your requirements could not be resolved to an installable set of packages.
Problem 1
- jms/security-extra-bundle 1.2.0 requires jms/metadata 1.1.* -> satisfiable by jms/metadata 1.1.1.
- jms/security-extra-bundle 1.2.0-RC requires jms/metadata 1.1.* -> satisfiable by jms/metadata 1.1.1.
- jms/security-extra-bundle 1.2.x-dev requires jms/metadata 1.1.* -> satisfiable by jms/metadata 1.1.1.
- Conclusion: don't install jms/metadata 1.1.1
- Installation request for jms/security-extra-bundle 1.2.* -> satisfiable by jms/security-extra-bundle 1.2.0, jms/security-extra-bundle 1.2.0-RC, jms/security-extra-bundle 1.2.x-dev.
View installation.sh
composer init -n --require=cypresslab/walrus:dev-develop && composer install
@matteosister
matteosister / Controller.php
Last active Dec 11, 2015
symfony2 @ facile.it
View Controller.php
<?php
// src/Acme/DemoBundle/Controller/MainController.php
class MainController
{
public function contactAction()
{
return new Response('<h1>Contact us!</h1>');
}
}