Skip to content

Instantly share code, notes, and snippets.

View proofek's full-sized avatar

Sebastian Marek proofek

  • Sheffield, United Kingdom
View GitHub Profile
@proofek
proofek / watchr.rb
Created March 9, 2011 10:45
watrchr and PHPUnit integration
watch('./(.*).php') { |m| code_changed(m[0]) }
def code_changed(file)
run "phpunit"
end
def run(cmd)
result = `cd Test && #{cmd}`
growl result rescue nil
end
@proofek
proofek / spl_directory.c
Created March 11, 2011 23:06
Make SplFileObject countable
/* {{{ proto int SplFileObject::count()
Get total number of lines */
SPL_METHOD(SplFileObject, count)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
long current_pos = intern->u.file.current_line_num;
long lines_number = 0;
if (zend_parse_parameters_none() == FAILURE) {
return;
@proofek
proofek / pre-receive
Created June 2, 2011 14:21
pre-receive git hook to run php linter
#!/usr/bin/php
<?php
echo "\nRunning php linter...\n";
$params = explode(' ', file_get_contents('php://stdin'));
$ref = trim($params[1]);
$diff = array();
$return = 0;
@proofek
proofek / phpunitAssertionsTest.php
Created February 9, 2012 10:55
phpunit assertion gotcha
<?php
class myClass
{
public function __toString()
{
return "mememe";
}
}
@proofek
proofek / composer.json
Created September 19, 2012 12:37
Install PHPUnit with composer
{
"name": "phpunit",
"description": "PHPUnit",
"require": {
"phpunit/phpunit": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "/tmp/bin/"
}
@proofek
proofek / default.rb
Created February 26, 2013 16:36
php tools install using php cookbook
include_recipe "php::#{node['php']['install_method']}"
channels = %w{pear.phpunit.de components.ez.no pear.symfony-project.com pear.symfony.com pear.pdepend.org pear.phpmd.org}
channels.each do |chan|
php_pear_channel chan do
action [:discover, :update]
end
end
packages = %w{PHP_CodeSniffer phpunit/PHPUnit pdepend/pdepend phpmd/PHP_PMD}
@proofek
proofek / SupplierRelate.php
Created June 18, 2013 21:44
SupplierRelate.php - definition of the 2 fields required for the relationship without middle table
<?php
/*
* Name relate field
* * link point at the link field defined below
* * make sure the field name matches the pattern <bean_name>_name
*/
$dictionary['Demo_SupplierContactDetails']['fields']['demo_suppliers_name'] = array(
'required' => true,
'source' => 'non-db',
@proofek
proofek / SupplierRelate.php
Last active December 18, 2015 16:18
SupplierRelate.php - definition of the relationship without middle table (see https://gist.github.com/proofek/5809737 for the field definitions)
<?php
/*
* Relationship link
* * see the link defined on the name field above
* * relationship name matches the relationship defined below
*/
$dictionary['Demo_SupplierContactDetails']['fields']['demo_suppliers'] = array(
'name' => 'demo_suppliers',
'type' => 'link',
@proofek
proofek / SupplierContactDetailsRelate.php
Created June 18, 2013 22:19
SupplierContactDetailsRelate.php - definition of the relationship on the parent module without middle table (see https://gist.github.com/proofek/5809737 for the field definitions and https://gist.github.com/proofek/5809899 for the child module relationship definition)
<?php
$dictionary['Demo_Suppliers']['fields']['demo_suppliercontactdetails'] = array(
'name' => 'demo_suppliercontactdetails',
'type' => 'link',
'relationship' => 'demo_suppliers_emis_suppliercontactdetails',
'module' => 'Demo_SupplierContactDetails',
'bean_name' => 'Demo_SupplierContactDetails',
'source' => 'non-db',
'vname' => 'LBL_SUPPLIER_CONTACTDETAILS',
@proofek
proofek / sugar.sql
Created June 18, 2013 22:29
SQL to alter demo_suppliercontactdetails and create the relationship
/* Table : demo_suppliercontactdetails */
/*COLUMNS*/
/*MISSING IN DATABASE - demo_suppliers_id - ROW*/
/* INDEXES */
ALTER TABLE demo_suppliercontactdetails add COLUMN demo_suppliers_id char(36) NULL ;