Skip to content

Instantly share code, notes, and snippets.

View ikwattro's full-sized avatar

Christophe Willemsen ikwattro

View GitHub Profile
@ikwattro
ikwattro / vat.export
Created June 18, 2012 13:21
vat rule export
{ "commerce_tax_type_vat" : {
"LABEL" : "Calculate taxes: VAT",
"PLUGIN" : "reaction rule",
"WEIGHT" : "10",
"REQUIRES" : [ "commerce_order", "commerce_tax", "commerce_product_reference" ],
"ON" : [ "commerce_product_calculate_sell_price" ],
"IF" : [
{ "commerce_order_compare_address" : {
"commerce_order" : [ "commerce-line-item:order" ],
"address_field" : "commerce_customer_billing|commerce_customer_address",
@ikwattro
ikwattro / parse.php
Created June 25, 2012 09:13
API Root page
<?php
public function indexAction()
{
$buzz = $this->container->get('buzz');
$headers = array(
'Accept: application/vnd.com.doggiiz.api+json'
);
$burl = 'http://localhost/~ikwattro/devapp/web/app_dev.php/front/hello';
$response = $buzz->call($burl, 'GET', $headers);
@ikwattro
ikwattro / login.php
Created June 25, 2012 11:23
Login form description in API
<?php
public function logsinAction()
{
$hypermedia = 'application/vnd.com.doggiiz.api+json';
$data = array(
'message' => 'Welcome to the login page',
'self' => 'http://localhost/~ikwattro/devapp/app_dev.php/front/logsin',
'_links' => array(
'home' => array(
'href' => 'http://localhost/~ikwattro/devapp/app_dev.php/front/logsin',
@ikwattro
ikwattro / prototype.js
Created July 16, 2012 10:42
protoype field
function addFieldForm(collectionHolder, $newLinkLi)
{
var prototype = collectionHolder.attr('data-prototype');
var newForm = prototype.replace(/__name__/g, collectionHolder.children().length);
var $newFormLi = jQuery('<li></li>').append(newForm);
$newLinkLi.before($newFormLi);
}
@ikwattro
ikwattro / proxy.php
Created July 19, 2012 09:59
Neo4j User Proxy Class
<?php
use HireVoice\Neo4j\Extension;
use HireVoice\Neo4j\EntityProxy;
use Doctrine\Common\Collections\ArrayCollection;
class neo4jProxyAcme_DemoBundle_Entity_User extends Acme\DemoBundle\Entity\User implements EntityProxy
{
private $neo4j_hydrated = array();
private $neo4j_meta;
private $neo4j_node;
<?php
namespace Retentio\Document;
use Retentio\Document\PasswordRequest;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
/**
* User
@ikwattro
ikwattro / add_dog.json
Created August 16, 2012 12:26
API Output
{
"template": {
"method": "POST",
"fields" : {
"chipnumber": {
"type": "alfanum",
"required": "true",
},
"name": {
"type": "alfanum",
@ikwattro
ikwattro / gist:3555276
Created August 31, 2012 16:15 — forked from chartjes/gist:3552838
Small sample lesson on mocking database operations
MOCKING DATABASE OPERATIONS
===========================
In our webreg example, we refactored some code so that we could
pass in our database object instead of creating it inside. Let's
push that further and show a slightly advanced usage of a mock
object.
So let's rework our Franchise test to use a mocked database connection.
@ikwattro
ikwattro / Cypher.java
Created September 1, 2012 13:32 — forked from jexp/Cypher.java
Cypher Queries
ExecutionEngine engine = new ExecutionEngine(graphDB);
String query = "start n=node:Person(name={name})
match n-[:ACTS_IN]->movie<-[:ACTS_IN]-friend
return friend";
ExecutionResult result = engine.query(query, map("name", "Keanu");
for (Map<String,Object> row : result) {
Node friend = row.get("friend");
}
@ikwattro
ikwattro / password_hashing_api.md
Created September 12, 2012 19:05 — forked from nikic/password_hashing_api.md
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.