Skip to content

Instantly share code, notes, and snippets.

View anunay's full-sized avatar
🏠
Working from home

Anunay Dahal anunay

🏠
Working from home
View GitHub Profile
@anunay
anunay / magento-perm-reset.sh
Created December 12, 2013 21:15
Magento shell directory and file permissions
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
chmod 775 -R var/ app/etc/ media/
@anunay
anunay / php-find-replace-db.php
Last active December 31, 2015 04:39
Wordpress: Find - Replace Database Table Values
<?php
// This script is to solve the problem of doing database search and replace
// when developers have only gone and used the non-relational concept of
// serializing PHP arrays into single database columns. It will search for all
// matching data on the database and change it, even if it's within a serialized
// PHP array.
// The big problem with serialised arrays is that if you do a normal DB
// style search and replace the lengths get mucked up. This search deals with
<?php
// cleanup.php?clean=var
// cleanup.php?clean=log
$xml = simplexml_load_file('./app/etc/local.xml', NULL, LIBXML_NOCDATA);
$db['host'] = $xml->global->resources->default_setup->connection->host;
$db['name'] = $xml->global->resources->default_setup->connection->dbname;
$db['user'] = $xml->global->resources->default_setup->connection->username;
<?php
$product=Mage::getModel("catalog/product");
$prod=$product->load($_product->getId());
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($prod);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
$total_qty=0;
foreach($col as $sprod){
$sprod=$product->load($sprod->getId());
@anunay
anunay / learning-stuffs.txt
Last active December 31, 2015 17:18
Things on my learning list:
elasticsearch - http://www.elasticsearch.org/
riako - http://docs.basho.com/
redis - http://redis.io/
graylog2 - http://graylog2.org/
rabbitMQ - http://www.rabbitmq.com/
http://requestb.in/
angularjs http://www.angularjs.org
@anunay
anunay / Menu.php
Created December 30, 2013 10:52
FuelCMS - Bootstrap Compatible Menu Class
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* FUEL CMS
* http://www.getfuelcms.com
*
* An open source Content Management System based on the
* Codeigniter framework (http://codeigniter.com)
*
* @package FUEL CMS
* @author David McReynolds @ Daylight Studio
@anunay
anunay / MY_Pagination.php
Created January 6, 2014 18:41
CodeIgniter: Digg Style Custom Pagination
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
@anunay
anunay / javascript-currency-formatter.js
Last active January 3, 2016 13:39
Javascript: Currency Format with (,) Seperator
/* Javascript Helper functions */
var MDHelperFx={
toCurrency:function(amount){
_amount = amount.toString();
return _amount.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ;
}
}
// Usage:
// MDHelperFx.toCurrency(amount);
@anunay
anunay / Dom-Info-Collector.php
Created January 30, 2014 20:37
DOM Example
<?php
include 'classes/simple_html_dom.php';
$html = file_get_html('http://www.wheel-size.com/');
$ret = $html->find('div[class=brand-icons] a');
$site_url = "http://www.wheel-size.com";
$wheel = array();
$modelelement = "";
$i = 0;
$csvdata = array();
$csvdata[] = array("Make","Year","Model","Tyre Size");
@anunay
anunay / gist:8799152
Created February 4, 2014 06:47
Temp file! (to be deleted)
<!-- ==================== BEGIN TAO VSL ================= -->
<!-- Offer Goal Conversion: Accelerated Seduction Program -->
<iframe src="https://badass.go2cloud.org/GL8" scrolling="no" frameborder="0" width="1" height="1"></iframe>
<!-- // End Offer Goal Conversion -->
<!-- ==================== END TAO VSL ================= -->
<!-- ==================== BEGIN FAW VSL (08122013) ================= -->
<!-- Offer Goal Conversion: Accelerated Seduction Program -->
<iframe src="https://www.trueclick.me/GLc" scrolling="no" frameborder="0" width="1" height="1"></iframe>
<!-- // End Offer Goal Conversion -->