Skip to content

Instantly share code, notes, and snippets.

View johnkary's full-sized avatar

John Kary johnkary

View GitHub Profile
<script type="text/javascript">
//Add 'ku_currentlinks' class to links in #leftnavigation if href matches exactly
currentnavnew();
//Add 'current' class to links in #leftnavigation if matches directory or a file in that directory
currentnavnew('leftnavigation', 'current');
//Add 'current' class to #tabbed_navigation links if href match exactly
currentnavnew('tabbed_navigation', 'current', true);
/**
* Checks all links within an HTML node and compares each link's href
@johnkary
johnkary / gist:634490
Created October 19, 2010 16:20
Using PHPUnit 3.5 MockBuilder to create a mock concrete object of an abstract class
<?php
//Create mock BaseCredential called 'MockAdminCredential' whose 'calculate'
//function will always return true. All other methods will return NULL
//as per the default behavior of a stub.
$this->mockAdminCredential = $this->getMockBuilder('BaseCredential')
->setMockClassName('MockAdminCredential')
->setMethods(array('calculate'))
->getMock()
->expects($this->any())
->method('calculate')
@johnkary
johnkary / gist:635035
Created October 19, 2010 20:27
What is best practice for building a mock used across several tests?
<?php
/**
* Having trouble building the same mock in my setUp() method.
* What is best practice for building a mock used across several tests?
*
* Error:
* 1) SystemUnderTestTest::testSecondTest
* PHPUnit_Framework_Exception: Class "MockStaffCredential" already exists.
*/
class SystemUnderTest
<?xml version="1.0" ?>
<ruleset name="My-PHPMD"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
MyRuleset...
</description>
@johnkary
johnkary / gist:989505
Created May 24, 2011 19:36
resty install
brew install resty
. resty
resty http://localhost:5984
GET /blogs.json
@johnkary
johnkary / KeyValueStoreForm.class.php
Created June 13, 2011 15:56
Assign sfDoctrineActAsKeyValueStorePlugin object values with forms
<?php
/**
* Allows key-value store values from objects with the ActAsKeyValueStore Doctrine
* behavior to be populated into form value defaults and also assigned/persisted
* to with the object using the form.
*
* @author John Kary <johnkary@ku.edu>
*/
abstract class KeyValueStoreForm extends sfFormDoctrine
@johnkary
johnkary / MyForm.class.php
Created June 13, 2011 16:00
Concrete form to store widget value for "tenure_years" in key-value store
<?php
class MyForm extends BaseDoctrineForm
{
public function setup()
{
//tenure_years, integer
$this->widgetSchema['tenure_years'] = new sfWidgetFormInputText();
@johnkary
johnkary / fancybox.1.3.4.ie6.ssl.fix.patch
Created September 1, 2011 16:36
Prevent IE6/7 from throwing security warning (substitute your own absolute URL to blank.gif on your server)
From d8c8d1bc3de5915cc3a7ad822170485750b8aaa4 Mon Sep 17 00:00:00 2001
From: John Kary
Date: Thu, 1 Sep 2011 11:17:20 -0500
Subject: [PATCH] [BREAK] Modify FancyBox 1.3.4 to not throw SSL warning in
IE6/7
See this thread:
http://wolfewebservices.com/blog/fancybox-ssl-security-warning-ie6-and-ie7
Basically, FancyBox creates a blank iFrame in IE6 to display the fancybox content.
@johnkary
johnkary / sfValidatorOffice2007File.class.php
Created October 25, 2011 15:43
Symfony 1 validator for Microsoft Office 2007 docs
<?php
/**
* Adds MIME-type guessers for Office 2007 documents
*
* @author John Kary <johnkary@ku.edu>
*/
class sfValidatorOffice2007File extends sfValidatorFile
{
/**
@johnkary
johnkary / page.html.twig
Created December 13, 2011 20:33
How to get Twig support for $$var like syntax?
{% for i in 0..50 %}
{% set someanswer = 'answer_' ~ i %}
{% if form.{{someanswer}} is defined %}
<div class="question">
{{ form_label(form.{{someanswer}}) }}
{{ form_errors(form.{{someanswer}}) }}
{{ form_widget(form.{{someanswer}}_0, {'attr': {'class':'test_choices'} }) }}
</div>
{% endif %}
{% endfor %}