Skip to content

Instantly share code, notes, and snippets.

@toopay
toopay / Juriya.php
Created October 23, 2012 12:44
Skip factory validation
// Try to transform path into socket name
// Change this lines
//try {
// $socket = Request::factory(implode('.', $request->getPath()),
// $request->getArguments(),
// $request->getTunnel())->getSocket();
//} catch (\Exception $e) {
// throw new \RuntimeException($e->getMessage());
//}
// into :
@toopay
toopay / routes.yml
Created October 23, 2012 12:47
Three level path router
# Default route rule
default:
controller: \App\ActionController
arguments:
- '/^[a-zA-Z]+$/'
action:
controller: \App\ActionController
arguments:
- '/^[a-zA-Z]+$/'
@toopay
toopay / ActionController.php
Created October 23, 2012 13:35
Action controller with arguments proxy
//...
/**
* Serve HTTP request
*
* @param string
* @param string
* @return response
*/
public function executeHttp($proxy = 'Home', $method = 'index', $id = NULL)
{
@toopay
toopay / CustomContent.php
Created October 25, 2012 04:45
Observer sample
<?php
namespace App;
use Juriya\Pattern\Observer;
use Juriya\ResponseHttp;
class CustomContent implements Observer {
public static function onExecute($observable, $arguments)
@toopay
toopay / core.php
Created November 6, 2012 09:29
Gas Core Class Patch
<?php namespace Gas;
/**
* CodeIgniter Gas ORM Packages
*
* A lighweight and easy-to-use ORM for CodeIgniter
*
* This packages intend to use as semi-native ORM for CI,
* based on the ActiveRecord pattern. This ORM uses CI stan-
* dard DB utility packages also validation class.
@toopay
toopay / selenium.sh
Created December 1, 2012 13:02
Bash Script to enable Selenium on Travis Hook
#!/bin/bash
case "${1:-''}" in
'start')
if test -f /tmp/selenium.pid
then
echo "Selenium is already running."
else
java -jar /usr/lib/selenium/selenium-server-standalone-2.21.0.jar > /var/log/selenium/selenium-output.log 2> /var/log/selenium/selenium-error.log & echo $! > /tmp/selenium.pid
echo "Starting Selenium..."
Vivas El Barca!
{"foo":"bar","lorem":"ipsum"}
@toopay
toopay / face.cpp
Last active December 16, 2015 22:39
C++ Face Detect
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
const char* keys =
{
"{i|input| |The source image}"
"{d|dir| |The resource directory}"
};
@toopay
toopay / face.py
Created May 3, 2013 10:04
Python Face Detect
import cv2
import sys
def detect(img,out):
color = (0,255,0)
cascade = cv2.CascadeClassifier("res/haarcascade_frontalface_alt.xml")
faces = cascade.detectMultiScale(img, 1.2, 2, 0, (100,100))
if (faces == None):
print "None found!"
else: