Exotic regular expression unicode scripts

I wrote this post on 1 minute read

After spending some time digging into Regular Expression while working on Polyglot, I learned about Unicode Scripts - a Regular Expression that matches a specific language’s scripting characters - currently supported in JGsoft engine, Perl, PCRE, PHP, Ruby 1.9, Delphi, and XRegExp. For example, a regular expression that matches all possible Japanese characters: /[\p{Hiragana}\p{Katakana}\p{Han}\p{Latin}]/ See the full list of Unicode Scripts on Regular-Expressions. Here is a piece of Ruby code I came up with to separate words for every language (hopefully), including lingual-continua scripts (does not have spaces between words):

Mina: Deploy Spree Commerce with Sidekiq, Unicorn and Nginx

I wrote this post on 11 minute read

Recently, I had a great time trying out Spree Commerce for the first time as a side project - an online store for my brother - which was also my crash course into a (somewhat serious) Rails project. Most of the steps are referenced from John McCartie’s blog post, with additional Spree-specific tweaks. I am using Spree 2.4 in this post. The idea is to keep the whole process copy/paste friendly as much as possible.

Grunt for Foundation 5 javascript

I wrote this post on 3 minute read

The Foundation 5 framework provides an extremely handy sass package with Grunt preinstalled - even Gruntfile.js is preconfigured to compile all Foundation’s sass file on the fly - Long live Foundation! Surprisingly, there is no Grunt configurations for javascript out of the box, despite js plays a significant part in the framework. The default workflow is then including foundation.min.js - choked with tons of custom Foundation js libraries, some of which is never used in our project.

Useful Drupal Commerce line_item wrapper methods and properties

I wrote this post on 2 minute read

A collection of useful Drupal commerce entity wrapper APIs that I was able to dig out from the core Drupal Commerce modules. All in one place for easy reference. At the moment, the listed methods only concern retrieving data. commerce_order_total->currency_code->value(); // order total object $order_total = $order_wrapper->commerce_order_total->value(); // subtotal without vat $total_ex_vat = commerce_price_component_total($order_total , 'base_price'); // total tax (in this case vat 20%) $total_vat = commerce_price_component_total($order_total , 'tax|vat_20'); // subtotal with vat $sub_total = $total_ex_vat['amount'] + $total_vat['amount']; // formatted price string with currency sign $sub_total = commerce_currency_format($sub_total, $currency_code); /** * LINE ITEM WRAPPER */ $line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item); // get all line item wrappers from order wrapper foreach ($order_wrapper->commerce_line_items as $line_item_wrapper) { // line item type $line_item_type = $line_item_wrapper->type->value(); // for product line items: if ($line_item_type == 'product') { // line item title $line_item_title = $line_item_wrapper->commerce_product->title->value(); // line item unit price $line_item_unit_price = $line_item_wrapper->commerce_unit_price->amount->value(); // line item formatted unit price $line_item_unit_price = commerce_currency_format($line_item_unit_price, $currency_code); // line item quantity $line_item_quantity = (float)$line_item_wrapper->quantity->value(); // line item total price $line_item_total_price = $line_item_wrapper->commerce_total->amount->value(); // line item formatted total price $line_iten_total_price = commerce_currency_format($line_item_total_price, $currency_code); // get product field data (for example field_product_image) $line_item_wrapper->commerce_product->field_product_image->value(); } else { // for shipping & discount line items // shipping/discount price $line_item_price = $line_item_wrapper->commerce_unit_price->amount->value(); // shipping/discount formatted price $line_item_price = commerce_currency_format($line_item_price, $currency_code); // line item TYPE display title $line_ite_type_title = commerce_line_item_type_get_name($line_item_wrapper->type->value()); // for shipping line items if ($line_item_wrapper->type->value() == "shipping") { // shipping data $shipping_data = $line_item_wrapper->value()->data; // shipping method display title $line_item_title = $shipping_data['shipping_service']['title']; } if ($line_item_wrapper->type->value() == 'commerce_discount') { // for discount line items // get discount display title (I suspect there might be a better way than this) $discount_data = $line_item_wrapper->commerce_unit_price->data->value(); foreach ($discount_data['components'] as $key => $component) { if (!

Installing LAMP stack on OSX Mavericks with Homebrew

I wrote this post on 8 minute read

Last week, as a turn of event, my 4-year-old mac did not recognize my hard drive and failed to boot. I instantly assumed that the hard drive was dead and bought a replacement SSD, only to find out it was the bad SATA cable that caused the problem. Got a new SATA cable from ebay and an upgrade to SSD - thanks to my hasty assumption. Now I have the old HDD sitting around for nothing, plus a Raspberry Pi rotting on the shelf.