Skip to content

Instantly share code, notes, and snippets.

function setPlacesAutocomplete(selector, value) {
casper.then(function () {
casper.sendKeys(selector, value, { keepFocus: true });
casper.page.sendEvent('keydown', 0);
casper.page.sendEvent('keyup', 0);
});
casper.waitUntilVisible('.pac-container .pac-item', function () {
casper.page.sendEvent('keydown', casper.page.event.key.Down);
casper.page.sendEvent('keydown', casper.page.event.key.Enter);
});
@jadell
jadell / benchmark.php
Created October 25, 2013 23:23
Performance benchmarks of neo4jphp streaming header vs. no streaming header, using curl and file stream transports
<?php
use Everyman\Neo4j\Client,
Everyman\Neo4j\Transport\Stream,
Everyman\Neo4j\Transport\Curl,
Everyman\Neo4j\Cypher\Query;
require_once 'example_bootstrap.php';
$transport = new Stream();
// $transport = new Curl();
@jadell
jadell / session_serialize.php
Last active June 21, 2018 01:29
Serialize PHP data like a PHP session
<?php
function session_serialize(array $data) {
$temp = $_SESSION;
$_SESSION = $data;
$out = session_encode();
$_SESSION = $temp;
return $out;
}
function session_unserialize($data) {
@jadell
jadell / manifests-site.pp
Last active December 16, 2015 13:19
Puppet manifests and templates for configuring an instance to talk to Loggly
class base_node {
loggly::device { "application_log": }
loggly::device { "apache_access": }
loggly::device { "apache_error": }
}
@jadell
jadell / loggly_api.js
Created April 13, 2013 03:50
Ajax query of Loggly from jQuery
$.ajax("https://mydomain.loggly.com/api/facets/date/?q=my_search_criteria", {
// Don't send the _=timestamp query parameter
cache: true,
// Send HTTP auth credentials
username: api_readonly_username,
password: api_readonly_password,
// Use JSONP
dataType: "jsonp"
}).done(function(data) {
// handle data, probably a call to some graphing library
@jadell
jadell / 0-initial.php
Created November 21, 2012 01:54
DI migration examples
<?php
// index.php
$app->get('/{id}', function ($id) use ($app) {
$controller = new Lal\HelloController();
return $controller->helloId($id);
});
$app->get('/', function () use ($app) {
$controller = new Lal\HelloController();
return $controller->index();
});
@jadell
jadell / cypher_delete.php
Created November 11, 2012 01:26
Delete nodes using a cypher query in neo4jphp
<?php
error_reporting(-1);
ini_set('display_errors', 1);
spl_autoload_register(function ($sClass) {
$sLibPath = __DIR__.'/../lib/';
$sClassFile = str_replace('\\',DIRECTORY_SEPARATOR,$sClass).'.php';
$sClassPath = $sLibPath.$sClassFile;
if (file_exists($sClassPath)) {
require($sClassPath);
}
@jadell
jadell / sudoredirect.sh
Created March 30, 2012 15:19
sudo redirect output
sudo sh -c 'ls -hal /root/ > /root/test.out'
@jadell
jadell / mutual.php
Created January 25, 2012 02:14
Mutual friends with Cypher
<?php
$client = new Everyman\Neo4j\Client();
$queryString =
"START firstPerson=node({firstId}), secondPerson=node({secondId}) " .
"MATCH firstPerson -[:FRIEND]-> mutualFriend <-[:FRIEND]- secondPerson" .
"RETURN mutualFriend";
$params = array(
"firstId" => 123,
@jadell
jadell / invoker.php
Created January 14, 2012 03:36
Command invoker pattern
<?php
interface Command
{
public static function register();
public function execute();
}
class HelloCommand implements Command {
protected $name;