Skip to content

Instantly share code, notes, and snippets.

View razbakov's full-sized avatar
🖖
Hi

Aleksey Razbakov razbakov

🖖
Hi
View GitHub Profile
@razbakov
razbakov / gist:714281
Created November 24, 2010 19:57
Just For Fun
We couldn’t find that file to show.
<?php
$db = mysql_connect ('localhost','root','12345');
mysql_query('SET NAMES UTF8');
mysql_query('SET character_set_client="UTF8"');
mysql_query('SET character_set_cоnnectiоn="UTF8"');
mysql_query('SET character_set_results="UTF8"');
mysql_query('SET character_set_server="UTF8"');
mysql_select_db ('blog,$db);
@razbakov
razbakov / vimeo.php
Created October 27, 2011 09:49
Show vimeo thumb with popup video
<?php if($vimeo = $_product->getVimeo()):
$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$vimeo.php"));
$img = $hash[0]['thumbnail_medium'];
?>
<script type="text/javascript">
jQuery(function($) {
$(".youtube-thumb a").fancybox({type:'iframe'});
});
</script>
<li class="youtube-thumb"><a title="<?php echo $this->__('Play Video') ?>" href="http://player.vimeo.com/video/<?php echo $vimeo; ?>?autoplay=1"> </a><img src="<?php echo $img; ?>"></li>
@razbakov
razbakov / functions.php
Created November 2, 2011 15:22
Добавляем список похожих записей в своем блоге
<?php
function related_posts_shortcode( $atts ) {
extract(shortcode_atts(array(
'limit' => '5',
), $atts));
global $wpdb, $post, $table_prefix;
if ($post->ID) {
@razbakov
razbakov / verif.js
Created November 3, 2011 14:10
Example jquery.validate.min.js
$(document).ready(function(){
$("#contactForm").submit(function(){
return $("#contactForm").validate();
})
});
@razbakov
razbakov / home_page_banner.html
Created November 7, 2011 14:34
Home page banner slides
<div id="slider">
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
</div>
@razbakov
razbakov / math.md
Created November 9, 2011 14:25
6:2*(1+2)=?

"I am your college professor that you requested, with a doctorate in Mathematics. I will break this down as simply as possible and end this debate as approx. 10 students have already asked me this today. The problem as it is written is 6÷2(1+2) , the ÷ cannot be substituted with a fraction bar because they have different ranks on the order of operations. It is an illegal math move to do this. The bar ranks with parentheses, ÷ is interchangeable with . therefore the problem must be solved as 6÷2(1+2) NOT 6 (over) 2(1+2) we do the parentheses first, so 6÷2(3), the parentheses are now no longer relevant, because the number inside is in it's simplest form. Every single number has implied parentheses around it. 6÷2(3) (6) ÷(2)(3) 6÷23, or even converting the division to multiplication by a reciprocal (a legal math move) (6)(1 (over) 2)(3) are all correct ways to write this problem and mean exactly the same thing. Using pemdas, where md and as are interchangeable, we work from left to right, so (3)(3) or 3*

@razbakov
razbakov / observer.php
Created December 2, 2011 13:58
Order Code
<?php
$order = new Mage_Sales_Model_Order();
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($incrementId);
/** @var $order Mage_Sales_Model_Order */
$cookieModel = Mage::getModel('core/cookie');
// Save order ad origin as order field
@razbakov
razbakov / shipment.php
Created December 7, 2011 14:46
Shipment
<?php
/** @var $order Mage_Sales_Model_Order */
$order = Mage::getModel('sales/order');
$order->load($orderId);
/** @var $shipment Mage_Sales_Model_Order_Shipment */
$shipment = Mage::getModel('sales/order_shipment');
$shipment->setOrder($order);
@razbakov
razbakov / template.php
Created December 9, 2011 17:27
Templates
<?php
class SomeClass {
public function somefunction()
{
$orderId = 1; // some order id for example
$order->load($orderId);
$vars['order_id'] = $order->getIncrementId();
$vars['order_date'] = $order->getCreatedAt();
$vars['order_day'] = date('d', strtotime($order->getCreatedAt()));