Skip to content

Instantly share code, notes, and snippets.

View casper-google-places-autocomplete.js
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 Oct 25, 2013
Performance benchmarks of neo4jphp streaming header vs. no streaming header, using curl and file stream transports
View benchmark.php
<?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 Jun 21, 2018
Serialize PHP data like a PHP session
View session_serialize.php
<?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 Dec 16, 2015
Puppet manifests and templates for configuring an instance to talk to Loggly
View manifests-site.pp
class base_node {
loggly::device { "application_log": }
loggly::device { "apache_access": }
loggly::device { "apache_error": }
}
@jadell
jadell / loggly_api.js
Created Apr 13, 2013
Ajax query of Loggly from jQuery
View loggly_api.js
$.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 Nov 21, 2012
DI migration examples
View 0-initial.php
<?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 Nov 11, 2012
Delete nodes using a cypher query in neo4jphp
View cypher_delete.php
<?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 Mar 30, 2012
sudo redirect output
View sudoredirect.sh
sudo sh -c 'ls -hal /root/ > /root/test.out'
@jadell
jadell / mutual.php
Created Jan 25, 2012
Mutual friends with Cypher
View mutual.php
<?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 Jan 14, 2012
Command invoker pattern
View invoker.php
<?php
interface Command
{
public static function register();
public function execute();
}
class HelloCommand implements Command {
protected $name;