Skip to content

Instantly share code, notes, and snippets.

View jmauerhan's full-sized avatar

Jessica Mauerhan jmauerhan

View GitHub Profile
@jmauerhan
jmauerhan / pogo.md
Created November 14, 2016 19:30
Pokemon Go Links

Pokemon Go

Links to become the world's best pokemon trainer

@jmauerhan
jmauerhan / pre-commit.php
Last active July 13, 2018 22:48
A pre-commit hook written in php to fix code style and alert about phpmd rules
#!/usr/bin/php
<?php
require __DIR__ . '/../../vendor/autoload.php';
/**
* Dependencies:
* - Symfony Console Component: symfony/console
* - Symfony Process Component: symfony/process
* - PHP Mess Detector: phpmd/phpmd
@jmauerhan
jmauerhan / wait.php
Last active August 5, 2017 21:34
Behat: Wait For AJAX Angular & jQuery
public function waitForAjax()
{
$waitTime = 10000;
try {
//Wait for Angular
$angularIsNotUndefined = $this->getSession()->evaluateScript("return (typeof angular != 'undefined')");
if ($angularIsNotUndefined) {
//If you run the below code on a page ending in #, the page reloads.
if (substr($this->getSession()->getCurrentUrl(), -1) !== '#') {
$angular = 'angular.getTestability(document.body).whenStable(function() {
@jmauerhan
jmauerhan / oauth1 example using generateSignature
Last active May 11, 2020 06:18
This is an example of using PHP's OAuth extension (available via PECL) to make a request to an API that requires a signature instead of access and refresh tokens. I was unable to find an example of how to do this, so hopefully if anyone else has to they will find this :)
<?php
define("CONSUMER_SECRET", "secret");
define("CONSUMER_KEY", "key");
define("TOKEN", "token");
define("TOKEN_SECRET", "token secret");
define("URL_API", "https://api.***");
$method = "GET";
$dql = "SELECT orderStatus.id
FROM \models\OrderStatus orderStatus
WHERE orderStatus.isCompleted = true";
var_dump($this->getEntityManager()->createQuery($dql)->getScalarResult());
getScalarResult Output:
array (size=1)
0 =>
array (size=1)
@jmauerhan
jmauerhan / Behat AfterScenario
Created June 2, 2015 17:38
An AfterScenario function for behat that takes and saves a screenshot
<?php
/** @AfterScenario */
public function after($event)
{
if($event->getResult() == Event\StepEvent::FAILED)
{
$imagePathPrefix = 'http://mysite.local';
errorImagesDir = '/';
@jmauerhan
jmauerhan / Robots and Marbles
Created May 28, 2015 22:47
Robots and Marbles
# Robots and Marbles
There are five robots, A, B, C, D, and E. Robot A is the oldest model, Robot E is the newest model.
When we give the robots a bag of 100 marbles, they will distribute the marbles among themselves following these rules:
1. The oldest robot will present a distribution of the marbles, divided however it has decided.
2. All robots will vote on whether or not to accept this distribution.
3. If 50% or more vote to accept the proposal, the marbles are distributed in that manner.
4. If less than 50% vote to accept the proposal, the oldest robot is automatically shut down, and the process starts over with the next oldest robot.
5. All robots have the following priorities and will vote according to these rules, in this order. They all know that they all share the priorities: