Skip to content

Instantly share code, notes, and snippets.

View tridungpham's full-sized avatar

Pham Tri Dung tridungpham

View GitHub Profile
@tridungpham
tridungpham / gist:5365126
Last active December 16, 2015 02:49
just a small dummy snippet
<html>
<head>
<script type="text/javascript">
<?php
$url = "http://google.com";
echo 'alert("Hello world");';
echo 'window.location="',$url,'"';
?>
</script>
</head>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Chương trình chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
Chỉnh sửa từ mã nguồn của anh NamNT
http://www.vithon.org/2009/06/14/x%E1%BB%AD-ly-ti%E1%BA%BFng-vi%E1%BB%87t-trong-python
"""
import re
INTAB = "ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđẠẢÃÀÁÂẬẦẤẨẪĂẮẰẶẲẴÓÒỌÕỎÔỘỔỖỒỐƠỜỚỢỞỠÉÈẺẸẼÊẾỀỆỂỄÚÙỤỦŨƯỰỮỬỪỨÍÌỊỈĨÝỲỶỴỸĐ"
@tridungpham
tridungpham / 1.php
Created June 20, 2013 09:44
Add suffix to renting price
<?php
static function format_price( $price = '', $no_price_text = 'Contact for price' ) {
/**
* @var PGL_Options $pgl_options
*/
global $pgl_options;
if ( ! $price ) {
return apply_filters( 'estate/format_price/noprice', $no_price_text );
}
else {
$html .= '<div class="row ' . ( $i < $items_per_big_column ? 'col-home' : '' ) . '">
<div class="span6">
<div class="container-big"><a href="'.get_permalink($the_id).'">
' . self::get_estate_thumbnail( $the_id, 'estate-showcase-big-thumbnail' ) . '</a>
<article class="text-big">
<div class="infotexthv">
<h3><a href="' . get_permalink( $the_id ) . '">' . get_the_title( $the_id ) . '</a></h3>
<p>' . PGL_Addon_Estate::the_excerpt( FALSE ) . '</p>
</div>
</article>
@tridungpham
tridungpham / select.js
Created August 13, 2013 08:30
Select the selected attachment when open gallery media.
// open
_media.frame.on('open',function() {
// add class
_media.frame.$el.closest('.media-modal').addClass('acf-media-modal acf-expanded');
//console.log( _media.frame.state() );
// set selection
var selection = _media.frame.state().get('selection'),
<?php
function is_right_format_col_1($val) {
// var_dump($val);
return is_numeric($val);
}
function is_right_format_col_2($val) {
return ! preg_match('/[^A-Za-z\s]/', $val);
}
@tridungpham
tridungpham / homepage
Created August 25, 2013 15:30
Demo code for homepage
[estate_search]
[estate_horizontal_slide count="10"]
[estate_list display="grid"]
[container extra_classes="ouragents"]
<h3>Our Agent</h3>
<div class="our-content">
[row][block size="6"][agent title="NO.1" name="JOHN SMITH" desc="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin rutrum nisi eu ante mattis sit amet luctus nisl tempus." mail="JohnSmith@gmail.com" phone="012.666.999" img="http://pixelgeeklab.com/realestast/img/our1.jpg"][/block][block size="6"][agent title="NO.2" name="ANDREW MCCARTHY" desc="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin rutrum nisi eu ante mattis sit amet luctus nisl tempus." mail="AndrewMccarthy@gmail.com" phone="012.666.999" img="http://pixelgeeklab.com/realestast/img/our2.jpg"][/block][/row]
</div>
[/container]
@color: #666;
@type: 'bold';
body{
background-color: @color;
font-weight: @type;
}
@tridungpham
tridungpham / new_gist_file.sql
Created December 4, 2013 10:28
Create new admin user in Magento with password "admin"
INSERT INTO admin_user SELECT
NULL `user_id`,
"Dung" `firstname`,
"Pham" `lastname`,
"dungpt@sutunam.com" `email`,
"dungpt.sutunam" `username`,
"9684dfd577831f73890e88fe18ca9072:Hs" `password`,
NOW() `created`,
NULL `modified`,
NULL `logdate`,
@tridungpham
tridungpham / test.xml
Created December 5, 2013 04:18
Test layout file
<richcart_product_view>
<label>Catalog Product View (Any)</label>
<!-- Mage_Catalog -->
<remove name="right"/>
<remove name="left"/>
<!-- <reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference> -->
<reference name="head">
<action method="addJs"><script>varien/product.js</script></action>