Skip to content

Instantly share code, notes, and snippets.

@zdenko
zdenko / dc_emw.php
Created Nov 22, 2016 — 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.
View dc_emw.php
<?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
Random password
View random_password.rb
def make_password(len)
len.times.map { [*'0'..'9', *'a'..'z', *'A'..'Z'].sample }.join
end
@zdenko
zdenko / flatten.php
Last active Jan 24, 2016
Function to recursively flatten multidimensional PHP array.
View flatten.php
<?php
function flatten_array($arg) {
return is_array($arg) ? array_reduce($arg, function ($c, $a) { return array_merge($c, flatten_array($a)); },[]) : [$arg];
}
You can’t perform that action at this time.