Skip to content

Instantly share code, notes, and snippets.

View mrsinguyen's full-sized avatar
🎯
Focusing

Si Nguyen mrsinguyen

🎯
Focusing
View GitHub Profile
@mrsinguyen
mrsinguyen / custom.module
Created December 28, 2011 02:35 — forked from mattfarina/custom.module
Protocol relative image paths in Drupal 7
<?php
/**
* Implementation of hook_preprocess_image().
*
* Make images that use a full url be protocol relative.
*/
function custom_preprocess_image(&$variables) {
// If the image URL starts with a protocol remove it and use a
@mrsinguyen
mrsinguyen / drupalvietnam.txt
Created February 7, 2012 08:47 — forked from and1truong/drupalvietnam.txt
Drupal Vietnam
Drupal Vietnam:
- http://drupalvietnam.org/
- http://groups.drupal.org/vietnam
- https://www.facebook.com/pages/Drupal-Vietnam/130401056619
- http://linkhay.com/drupal
@mrsinguyen
mrsinguyen / element.inc
Created February 27, 2012 04:38 — forked from pixelwhip/element.inc
Creates an element object as a basis for a more consistent render array.
<?php
/**
* @file
* Creates an element object as a basis for a more consistent render array.
*
* The current Drupal 7 render array is very powerful but hard to manage due to
* inconsistencies and information overload. This proof of concept aims to
* create a better separation between what is meant to be rendered and what is
* extra contextual information used by module developers. It tries to strike
* a balance between flexibility and discoverability. The general idea is
@mrsinguyen
mrsinguyen / get_barcode_from_image.js
Created April 12, 2012 14:26 — forked from tbtlr/get_barcode_from_image.js
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@mrsinguyen
mrsinguyen / strip_info.php
Created May 4, 2012 02:49 — forked from joshkoenig/strip_info.php
Strip drupal.org packaging data from core .info files
<?php
/**
* Quick script for stripping drupal packaging info.
*
* Run in the drupal root, or specify the root as an argument. E.g.:
*
* php strip_info.php path/to/drupal
*
*/
@mrsinguyen
mrsinguyen / htmlfiles_migration.inc.php
Created May 5, 2012 09:02 — forked from marktheunissen/htmlfiles_migration.inc.php
HTML Files Migration into Drupal using Migrate
<?php
class MyMigration extends Migration {
public $base_dir;
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
@mrsinguyen
mrsinguyen / gist:2835360
Created May 30, 2012 10:28 — forked from cmer/gist:1566734
UnixBench comparison of EC2 and Joe's Data Center
apt-get install -y build-essential libx11-dev libgl1-mesa-dev libxext-dev perl perl-modules make
cd /tmp
wget http://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz
tar xzvf UnixBench5.1.3.tgz
cd UnixBench
./Run
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@mrsinguyen
mrsinguyen / de_migration_product.inc
Created June 8, 2012 02:57 — forked from btmash/de_migration_product.inc
DE Migration Example SOURCE::DESTINATION code
<?php
class DEMigrationCommerceProductMigration extends Migration {
protected $file_public_path = "";
protected $source_drupal_root = "";
public function __construct() {
parent::__construct();
$this->systemOfRecord = Migration::DESTINATION;
@mrsinguyen
mrsinguyen / ConfigObject.php
Created June 8, 2012 03:05 — forked from sun/ConfigObject.php
simple config object
<?php
namespace Drupal\Core\Config;
use Drupal\Core\Config\StorageInterface;
class ConfigObject {
protected $name = '';