Skip to content

Instantly share code, notes, and snippets.

View ybouhjira's full-sized avatar

Youssef Bouhjira ybouhjira

View GitHub Profile
@ybouhjira
ybouhjira / rx-distib.js
Last active October 25, 2016 01:42
Distribute stream on an other stream
console.clear();
const items$ = Rx.Observable
.interval(100)
.map(x => `item-${x}`)
.take(100)
.share();
const cc$ = Rx.Observable
.interval(0)
@ybouhjira
ybouhjira / rx-distib.js
Created October 24, 2016 02:00
Distribute stream on an other stream
console.clear();
const items$ = Rx.Observable
.interval(100)
.map(x => `item-${x}`)
.take(100)
.share();
const cc$ = Rx.Observable
.interval(0)
@ybouhjira
ybouhjira / DoctrineTrait.php
Created May 19, 2016 00:20
Doctrine shortcuts
<?php
namespace AppBundle\Utils;
use ReflectionClass;
trait DoctrineTrait
{
/**
* Deduces the entity's name from the controller name
@ybouhjira
ybouhjira / DoctrineRelationProvider.php
Created May 16, 2016 22:52 — forked from jdachtera/DoctrineRelationProvider.php
Automatically generate HATEOAS links for doctrine relations
<?php
namespace Acme\FooBundle\Hateoas;
use Doctrine\ORM\EntityManager;
use Hateoas\Configuration\Metadata\ClassMetadataInterface;
use Hateoas\Configuration as Hateoas;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouterInterface;
@ybouhjira
ybouhjira / routeview.sh
Created March 22, 2016 21:29
Transforming artisan's routes:list ouput to a readable format
#!/bin/bash
while read line; do
if ! echo $line | grep '+----' &> /dev/null ; then
echo $line | sed -E 's/\s+/ /g' | awk -F '\\s*\\|\\s*' '{ print $0 }' | tr '|' "\n"
fi
done
@ybouhjira
ybouhjira / web.xml
Created February 16, 2016 11:14
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>AuthServlet</servlet-name>
<servlet-class>AuthServlet</servlet-class>
</servlet>
@ybouhjira
ybouhjira / stl_examples.cpp
Last active January 18, 2016 11:41
STL examples
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <iterator>
#include <functional>
#include <vector>
#include <list>
@ybouhjira
ybouhjira / client.cpp
Created January 4, 2016 09:08
Echo client
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <boost/asio.hpp>
using boost::asio::ip::udp;
enum { max_length = 1024 };
int main(int argc, char* argv[])
@ybouhjira
ybouhjira / echo_server.cpp
Last active January 4, 2016 09:07
Echo server
#include <cstdlib>
#include <iostream>
#include <boost/asio.hpp>
#include <functional>
using boost::asio::ip::udp;
class server
{
public:
#include <iostream>
#include <boost/array.hpp>
#include <boost/asio.hpp>
using boost::asio::ip::tcp;
namespace as = boost::asio;
int main(int argc, char* argv[])
{