Skip to content

Instantly share code, notes, and snippets.

@jadell
jadell / Jaded_ContollerExample.php
Created November 21, 2010 18:22
Example of using JadedPHP controllers, filters and filter chains.
<?php
// initialize the JadedPHP library here
class MyController extends Jaded_Controller
{
protected function process(Jaded_Request $oRequest, Jaded_Response $oResponse)
{
$oResponse->assign('myVar', 'this is the assigned value');
$oResponse->assign('requestVar', $oRequest->getParam('reqParam'));
}
@jadell
jadell / httpd.conf
Created December 17, 2010 14:02
Dynamic Subdomains in Apache
RewriteEngine on
# look for URLS like 'subdir.username.foo.bar'
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ([^.]+)\.([^.]+)\.foo\.bar$
RewriteCond /home/%2/public_html/%1 -d
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ([^.]+)\.([^.]+)\.foo\.bar(?::\d+)?(.*) /home/$2/public_html/$1$3 [L]
# look for URLS liks 'username.foo.bar'
RewriteCond %{ENV:REDIRECT_STATUS} ^$
@jadell
jadell / instance_id.sh
Created March 15, 2011 21:13
AWS Instance ID from tag
# Assuming an instance tagged with Foo=bar
# Using the aws-tools
ec2-describe-tags --filter key=Foo value=bar | cut -f3
@jadell
jadell / socket_file.sh
Created March 15, 2011 21:22
Read and write to a socket using only Bash
#!/bin/bash
#
# Bash must have been compiled with this ability: --enable-net-redirections
# The device files below do not actually exist.
# Use /dev/udp for UDP sockets
exec 3<>/dev/tcp/host/port
# Write to the socket as with any file descriptor
echo "Write this to the socket" >&3
@jadell
jadell / batch_benchmark.php
Created August 24, 2011 22:04
benchmark script for neo4jphp batch
#!/usr/bin/env php
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
Everyman\Neo4j\Batch,
Everyman\Neo4j\Relationship,
Everyman\Neo4j\Node;
error_reporting(-1);
ini_set('display_errors', 1);
@jadell
jadell / batch_benchmarks.php
Created August 28, 2011 19:30
benchmark script for neo4jphp, multiple scenarios
#!/usr/bin/env php
<?php
namespace Everyman\Neo4j;
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
Everyman\Neo4j\Batch,
Everyman\Neo4j\Relationship,
Everyman\Neo4j\Node;
error_reporting(-1);
ini_set('display_errors', 1);
@jadell
jadell / modify.php
Created October 5, 2011 03:03
Copy-on-write vs. reference
<?php
echo "\nCopy-on-write:\n";
$a = array(array("result" => "a"));
for ($i=0; $i < 2; $i++) {
foreach ($a as $j => $v) {
$v["result"] .= "a";
echo $v["result"] ."\n";
}
}
@jadell
jadell / carelink.user.js
Created October 18, 2011 01:58
Use Minimed's CareLinksite from Chrome.
@jadell
jadell / Actor.php
Last active June 2, 2016 07:55
Neo4j and PHP sample application
<?php
use Everyman\Neo4j\Node,
Everyman\Neo4j\Index;
class Actor
{
public $id = null;
public $name = '';
protected $node = null;
@jadell
jadell / utf-8.php
Created November 20, 2011 17:47
UTF-8 with Neo4jPHP
#!/usr/bin/env php
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
Everyman\Neo4j\Index,
Everyman\Neo4j\Relationship,
Everyman\Neo4j\Node;
error_reporting(-1);
ini_set('display_errors', 1);