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 / php-month-number-to-month-name.php
Created June 12, 2013 23:18
PHP: Month Number to Month Name
<?php
$monthNum = 5;
$monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
echo $monthName; //output: May
@anunay
anunay / CSV-2-PHP-Array.php
Last active January 5, 2022 19:38
Convert a CSV file to a PHP associated array
<?php
function csv_to_array($filename='', $delimiter=',')
{
if(!file_exists($filename) || !is_readable($filename))
return FALSE;
$header = NULL;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE)
{
@anunay
anunay / scroller.html
Created September 22, 2013 16:42
Javascript: Status Scroller
<script type="text/javascript">
var message = "Scroller text goes here";
var space = "";
var i = 0;
function scroller(){
if(i < 100){
space += " ";
}
window.status = space + message;
}
@anunay
anunay / magento-get-controller-name.php
Created October 3, 2013 19:29
Magento: Get Controller Name
<?php if( $this->getRequest()->getControllerName() !== 'onepage') { ?>
// your javascript statements goes here
<?php } ?>
@anunay
anunay / magento-homepage-check.php
Created October 3, 2013 19:42
Magento: Check Homepage
<?php if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home' &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'
) : ?>
<!-- CONTENT GOES HERE -->
<?php endif; ?>
@anunay
anunay / magento-homepage-check-v2
Last active December 24, 2015 14:49
Magento: Homepage Check V2
<?php
if($this->getUrl('') == $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))):
echo "Homepage";
else:
echo "Not in Homepage";
endif;
var gistPrefix = 'http://gist.github.com/',
// Cache document.write so that it can be restored once all Gists have been
// embedded.
cachedWrite = document.write,
body = $('body'),
// Map each p.gist to an object that contains the paragraph to be replaced
// and the Gist's identifier.
gists = $('p.gist').map(function(n, p) {
p = $(p);
@anunay
anunay / wordpress-youtube-thumb.php
Last active December 29, 2015 01:39
Wordpress Youtube Thumbnail
<?php
function wordpress_youtube_thumbnail($content){
preg_match("/v\/([^*]+)/i", $content, $matches);
$matches[1] = preg_replace("/\?/","&",$matches[1]);
if($matches[1]=="" || empty($matches[1])){
preg_match("/watch\?v=([^*]+)/i", $content, $matches);
$matches[1] = preg_replace("/\?/","&",$matches[1]);
}
$images = explode("&",$matches[1]);
//http://img.youtube.com/vi/bQVoAWSP7k4/1.jpg
@anunay
anunay / autoconf-phpize-xampp
Last active July 16, 2021 10:52
Installing AutoConf and Fixing Phpize on OSX 10.9
Installing AutoConf and Fixing Phpize on OSX 10.9
@anunay
anunay / fix-magento-httponly-issue
Created December 3, 2013 05:01
Fix magento 'httponly' error.
Fix Magento 'httponly' issue
============================