Skip to content

Instantly share code, notes, and snippets.

@zdenko
zdenko / dc_emw.php
Created November 22, 2016 03:34 — forked from BBGuy/dc_emw.php
Working with Drupal commerce entities using entity_metadata_wrapper. Just a bunch of exampled copied from the web or added by me. will keep adding over time.
<?php
// order.
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Order id.
$order_id = order_wrapper->order_id->value();
// User detils.
@zdenko
zdenko / random_password.rb
Last active May 14, 2016 06:56
Random password
def make_password(len)
len.times.map { [*'0'..'9', *'a'..'z', *'A'..'Z'].sample }.join
end
@zdenko
zdenko / flatten.php
Last active January 24, 2016 01:39
Function to recursively flatten multidimensional PHP array.
<?php
function flatten_array($arg) {
return is_array($arg) ? array_reduce($arg, function ($c, $a) { return array_merge($c, flatten_array($a)); },[]) : [$arg];
}