Skip to content

Instantly share code, notes, and snippets.

View sveneisenschmidt's full-sized avatar
🚀

Sven Eisenschmidt sveneisenschmidt

🚀
View GitHub Profile
@sveneisenschmidt
sveneisenschmidt / benchmark--21-02-2010
Created February 21, 2011 09:17
ApacheBench with 10000 requests (8 simoustanly requets) running against a pint.io server with 8 workers.
sven@sven-work:~/Arbeitsplatz/Projekte/pint$ ab -n 10000 -c 8 localhost:3000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
function array_path($array, $path) {
$matches = preg_split("/\[|\]/", $path, -1, PREG_SPLIT_NO_EMPTY);
if(empty($matches)) {
return null;
}
$data = $array;
foreach($matches as $key) {
if(!array_key_exists($data, $matches)) {
return null;
}
@sveneisenschmidt
sveneisenschmidt / api-bundle.php
Created June 15, 2011 19:49
Expose Entities via annotations
namespace MyCompany\MyBundle\Entity;
use Hahaitsfate\ApiBundle\Mapping\Annotations as Api;
/**
* @API\Collection(name="products")
* @ORM\Table(name="products")
* @ORM\Entity
*/
class Product
@sveneisenschmidt
sveneisenschmidt / silex-cli-routing-class.php
Created February 7, 2012 10:56
Silex CLI Routing Prototype (Class)
<?php
namespace App\Provider;
use Silex\Application;
use Silex\ServiceProviderInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@sveneisenschmidt
sveneisenschmidt / main.sh
Created February 29, 2012 16:18
Parallel execution of bash scripts
#!/bin/bash
declare -a status=()
declare -a threads=(
[0]='sh ./thread-sleep-5.sh'
[1]='sh ./thread-sleep-10.sh'
[2]='sh ./thread-sleep-3.sh'
)
date
@sveneisenschmidt
sveneisenschmidt / main.py
Created March 1, 2012 10:08
Parallel execution of scripts with Python
import subprocess
import os
import time
import pprint
import sys
steps = [
[
['sh', './thread-sleep-5.sh'],
['sh', './thread-sleep-3.sh'],
@sveneisenschmidt
sveneisenschmidt / app.php
Created June 14, 2012 11:09
Silex on Raspberry Pi
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/', function () {
$uname = shell_exec('uname -a');
return "<img src='logo.jpg' style='width:26px; height:26px; float: left;' /><h3>Hello says <em>Silex</em> running on <em>Raspberry Pi</em>!</h3></br>> php shell_exec('uname -a')<br/> <code>{$uname}</code>";
<em>Silex<$
});
@sveneisenschmidt
sveneisenschmidt / gist:3128541
Created July 17, 2012 10:07
cannot load such file -- dispatcher
redmine@Sparta:/opt/redmine/2.0.3-icmaa$ rake redmine:plugins:migrate RAILS_ENV=production --trace
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
cannot load such file -- dispatcher
/var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
/var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
/var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
@sveneisenschmidt
sveneisenschmidt / DefaultController.php
Created October 26, 2012 08:09
Wildly\Bundle\BackendBundle\Controller\DefaultController
/**
*
* @Template()
*/
public function indexAction()
{
return array(
'creatures' => $this->getNewEntities('WildlyCoreBundle:Creature', 5),
'locations' => $this->getNewEntities('WildlyCoreBundle:Location', 5),
);
@sveneisenschmidt
sveneisenschmidt / dispatch.php
Created November 11, 2012 08:53
Messae Queue Syntax
$this->get('wildly.queue')->dispatch('upload.picture.amazons3', array(
'entity_id' => 14,
'entity_class' => '@WildlyCoreBundle:Modifier'
));