Skip to content

Instantly share code, notes, and snippets.

View and1truong's full-sized avatar
🎯

Hong Truong and1truong

🎯
View GitHub Profile

Features

  • Lazy load.
  • Simple configuration system.
  • YAML configuration style for hooks: permission, menu, theme, views.
  • Auto run path/to/module/lib/Cron.php > {ModuleName}Cron->cron*().

Function Callback Wrapper

Support annotations.

<?php
$provider_linode = new VietCoop\System\Hosting\Provider\Linode();
$provider_linode->setAppKey('…');
$cmd_register = new Vietcoop\System\Hosting\Command\Register();
$cmd_register->setProvider($provider_linode);
try {
$cmd_register->process();
}
// JavaScript Document
(function($){
Drupal.behaviors.lang_dropdown.attach = function(context, settings) {
$('.arrow-button').click(function () {
if( $('.block-main-menu .content ul.menu').css('height') == '38px') {
$('.block-main-menu .content ul.menu').css("height","306px");
$('.zone-branding-wrapper').css("height", "306px");
$('header').css("height", "306px");
<?php
/**
* @file lib/Lazy/Content.php
*/
class Vc_Lazy_Content {
public static function trying() {
$file = '/path/to/system_members_stats.yaml';
if (!$content = yaml_parse_file($file)) return FALSE;
$tokens = self::buildMetaToken($content);
@and1truong
and1truong / read.md
Created November 18, 2012 10:47
Gửi Tom Tran, GeekPolis

Tom Tran, tôi không phủ nhận nổ lực của anh. Nhưng quả thật anh đã coi cái tôi của mình quá lớn và không tôn trọng anh em khác. Việc anh đang làm ở đây như một thằng hề không hơn không kém.

Đi vào issue ở d.o #1821062, ở comment #9 của Sang, bằng chứng anh không thể nào chối cãi:

(1) Chúng ta, bao gồm anh, đã thống nhất thành lập website DrupalVietnam.org sau nhiều năm sinh hoạt cộng đồng ở group này.

(2) Mỗi người một việc để để lo cho event diễn ra tốt. Ở vị trí của anh, có tài ngoại giao, ăn nói, tổ chức, … đáng ra anh phải là người đứng ra tổ chức event này. Nhưng không, anh hùng hồn tuyên bố: Tài trợ theme cho DrupalVietnam.org để rồi năm lần bảy lược anh em nhắc nhỏ, anh nói: đang làm, đang làm, đang làm, …mặt mũi cái theme đang làm ra sao, không ai trên thế giới này có cơ hội được nhìn biết.

Xin lỗi, anh không hề xin lỗi. Anh chẳng nói gì cả. Lần #1: "Anh là nguỵ quân tử"

<?php
function field_collection_remove_submit($form, &$form_state) {
$button = $form_state['triggering_element'];
$delta = $button['#delta'];
// Where in the form we'll find the parent element.
$address = array_slice($button['#array_parents'], 0, -2);
// Go one level up in the form, to the widgets container.
$parent_element = drupal_array_get_nested_value($form, $address);
@and1truong
and1truong / gist:4116628
Created November 20, 2012 07:47 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> node-<?php print $type; ?> node<?php print ($page) ? '-page' : '-teaser'; ?> node-<?php print $type; ?><?php print ($page) ? '-page' : '-teaser'; ?> clear-both">
<?php print $user_picture; ?>
<?php if (!$page): ?>
<h2 class="node-title"><a href="<?php print $node_url; ?>" title="<?php print $title; ?>"><?php print $title; ?></a></h2>
<?php endif; ?>
<?php if ($display_submitted): ?>
<div class="submitted"><?php print $submitted; ?></div>
<?php endif; ?>
@and1truong
and1truong / get-file-object-from-embed-code.php
Created November 29, 2012 07:34
Get file object from embed code #drupal #media
<?php
$embed_string = '[ted id=1204]';
$provider = media_internet_get_provider($embed_string);
$file = $provider->save();
dsm($file);
<?php
if (empty($_GET['url'])) {
if (empty($_SERVER['QUERY_STRING'])) exit;
$_GET['url'] = $_SERVER['QUERY_STRING'];
}
define('CACHE_DIR', '/home/truongthehong/.wget_cache');
$url = $_GET['url'];