Skip to content

Instantly share code, notes, and snippets.

View ftdysa's full-sized avatar

Fred Dysart ftdysa

  • Automox
  • Denver, CO
View GitHub Profile
<?php
namespace Project\WebsiteBundle\Tests;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\HttpFoundation\Session\Session;
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="build-parallel">
<target name="build" depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,behat,phpdox"/>
<target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,behat,phpdox"/>
<target name="tests" depends="prepare,phpunit,behat"/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="4">
<sequential>
@ftdysa
ftdysa / PaymentType.php
Created March 17, 2014 20:41
Injecting services into form types
<?php
namespace Project\WebsiteBundle\Form\Type\Payment;
use Doctrine\ORM\EntityRepository;
use Entity\Core\Account;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
@ftdysa
ftdysa / gist:11192140
Created April 22, 2014 19:52
jms serializer
jms_serializer:
metadata:
directories:
core:
namespace_prefix: Entity\Core
path: "@ProjectApiBundle/Resources/config/serializer"
postfix:
namespace_prefix: Entity\Postfix
path: "@ProjectApiBundle/Resources/config/serializer"
nms:
$builder->add('secretQuestion', 'entity', [
'property' => 'question',
'class' => 'E:SecretQuestion',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('q')->orderBy('q.id', 'ASC');
}
]);
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@ftdysa
ftdysa / make-tags.js
Created September 14, 2014 03:03
Get all tags for ghost
var config = require('./../../../../config');
var sqlite3 = require('sqlite3');
var dbfile = config.development.database.connection.filename;
var db = new sqlite3.Database(dbfile);
db.serialize(function() {
db.all("select * from tags", function(err, rows) {
console.log(JSON.stringify(rows));
})
@ftdysa
ftdysa / ghost-api.js
Created September 14, 2014 19:15
Example of accessing ghost's api. Check out core/server/routes/api.js for more routes you can hit.
var querystring = require('querystring');
var http = require('http');
var fs = require('fs');
var requester = require('request');
var postData = querystring.stringify({
grant_type: "password",
username: "your_email",
password: "password",
client_id: "ghost-admin"
@ftdysa
ftdysa / SuccessHandler.php
Created September 18, 2014 19:51
Custom login success handler
<?php
namespace NationalNet\MynatnetBundle\Security\Authentication\Handler;
use NationalNet\MynatnetBundle\Manager\UserManager;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post