Skip to content

Instantly share code, notes, and snippets.

View ryanotella's full-sized avatar

Ryan ryanotella

  • NSW Department of Education
  • Sydney, Australia
View GitHub Profile
<?php
/** @ORM\Entity */
class AttributeType
{
/**... */
private $id;
/** @ORM\Column(type="string") */
private $name;
@ryanotella
ryanotella / AddAdditionalFields.php
Last active January 2, 2016 08:49
Symfony 2.2: Dynamic disabled fields. This won't
<?php
namespace Crana\OrdersBundle\EventListener;
use Symfony\Component\Form\Event\DataEvent;
use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\FormConfigInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@ryanotella
ryanotella / base.html.twig
Created May 20, 2014 07:41
KnpMenu and base.html.twig
<div class="nav-collapse collapse">
{{ knp_menu_render('TaliceAdminBundle:Menu:main', { 'allow_safe_labels': true , 'nav_type': 'navbar' }) }}
<div class="navbar-text navbar-user pull-right">
<div>
<a id="logoutLink"
data-shift="{{ shift_active() ? 'yes' : 'no' }}"
href="{{ path("user_logout_end_shift") }}">
<i class="icon-off icon-white"></i>
</a>
@ryanotella
ryanotella / logrotate.conf
Created February 12, 2015 00:25
Example logrotate.conf
/home/user/app/logs/prod.log {
create 600 user group
notifempty
daily
rotate 14
missingok
compress
mail email@address
}
@ryanotella
ryanotella / error.log
Created March 6, 2015 02:52
MySQL error frequency
[2015-02-11 08:31:02] request.CRITICAL: Uncaught PHP Exception PDOException: "SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)" at .../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php line 40 {"exception":"[object] (PDOException(code: 2003): SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111) at .../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:40)"} {"token":"-daed1082","user":"Anonymous"}
[2015-02-11 08:31:02] request.CRITICAL: Uncaught PHP Exception PDOException: "SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)" at .../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php line 40 {"exception":"[object] (PDOException(code: 2003): SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111) at .../vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:40)"} {"token":"-daed0da1","user":"Anonymous"}
[2015-02-11 08:31:05] request.CRITICAL: Uncaught PHP Exception PDOException:
@ryanotella
ryanotella / google-drive-restore.php
Last active August 29, 2015 14:19
Using Google Drive API to restore files removed from shared folders
<?php
/**
* Requires "google/apiclient"
*/
class GoogleDriveRestore
{
/** @var Google_Client */
private $client;
@ryanotella
ryanotella / entity-health.php
Created April 30, 2015 05:17
Hydrate all entities in the system
<?php
$doctrine = ...;
foreach ($entities as $entity) {
$metadata = $doctrine->getEntityManager()->getClassMetadata($entity);
$query = $doctrine->getEntityManager()->getRepository($entity)->createQueryBuilder('o');
foreach ($metadata->getAssociationMappings() as $association) {
$query->setFetchMode($entity, $association, 'EAGER');
}
try {
@ryanotella
ryanotella / Contact.php
Last active December 3, 2015 01:29
Order Customer Selector with optional exclusion of archived contacts
<?php
class Contact
{
/* @var Order[] */
private $orders;
/** @var bool */
private $deleted;
<p>Should you have any log in issues, content issues or need clinical support, please contact <strong>[email protected]</strong>.</p>
<p>For navigational help please copy and paste this link into your search engine
<em>http://eremote.crana.org.au/moodle/site_wide_files/UserGuide_eRemote_Vxx.pdf</em></p>
<p>This will take you to a user guide to be printed or saved to your computer to help you navigate around the
program.</p>
{% endif %}
<p>Regards,</p>
<p>eRemote Coordinator<br>
@ryanotella
ryanotella / checkout.js
Created December 1, 2016 04:46
Generic field duplicate check
$('[data-duplicate-check]').on('keyup change', '[data-duplicate-check-url]', _.debounce(function () {
var $field = $(this);
if($field.val().length < 3) {
return;
}
$.ajax({
url: $field.attr('data-duplicate-check-url'),
data: {value: $field.val()}
}).done(function (data) {
$field.parent().find('.alert-box').remove();