Skip to content

Instantly share code, notes, and snippets.

View ashfame's full-sized avatar
💭
What parts of our society are best governed by code?

Ashish Kumar ashfame

💭
What parts of our society are best governed by code?
View GitHub Profile
@ashfame
ashfame / generate-thumbnails.php
Created August 5, 2012 11:02 — forked from Viper007Bond/generate-thumbnails.php
WordPress: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
<?php /*
**************************************************************************
Plugin Name: Generate Thumbnails On The Fly
Description: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
Version: 1.0.0
Author: Alex Mills (Viper007Bond)
Author URI: http://www.viper007bond.com/
@ashfame
ashfame / modify-page-title.php
Created August 3, 2012 15:43
Modifying page title using the_title filter in WordPress
<?php
add_filter( 'the_title', 'nine11day_modify_post_title' );
function nine11day_modify_post_title( $title ) {
if ( is_page() && in_the_loop() && $title == 'Existing Title' )
$title = '<span>Existing</span> Title';
return $title;
}
@ashfame
ashfame / functions.php
Created August 3, 2012 11:12
Add page slug to body class
<?php
function custom_body_class($classes){
global $wp_query;
if ( is_page() ) {
$post_obj = $wp_query->get_queried_object();
array_push($classes, 'slug-'.$post_obj->post_name);
}
return $classes;
@ashfame
ashfame / config.xml
Created May 4, 2012 20:26
Overriding admin template in magento
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Anattadesign_Adminoverrider>
<version>1.0.0</version>
</Anattadesign_Adminoverrider>
</modules>
<global>
<layout>
<adminhtml_sales_order_create_index>
@ashfame
ashfame / useful-shell-commands.sh
Created March 1, 2012 17:20
Useful shell commands
# Set 644 permission on all PHP files recursively
find . -type f -name '*.php' -exec chmod 644 '{}' \+
@ashfame
ashfame / Correct-way-to-enqueue-scripts-and-style-in-WordPress.php
Created February 27, 2012 13:36
Correct way to enqueue scripts and style in WordPress
<?php
/**
* Register Styles and Scripts
*/
add_action( 'wp_enqueue_scripts', 'ft_scripts_styles' );
function ft_scripts_styles() {
@ashfame
ashfame / local-config-awesome-wp-config-file.php
Created February 27, 2012 13:34
Local config file to hold db credentials and for defining keys & salts along with the use of awesome wp-config.php file
<?php
/**
* WordPress config file to use one directory above WordPress root, when awesome version of wp-config.php is in use.
*
* Awesome wp-config.php file - https://gist.github.com/1923821
*/
/* WordPress Local Environment DB credentials */
@ashfame
ashfame / awesome-wp-config-file.php
Created February 27, 2012 13:30
awesome-wp-config-file
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@ashfame
ashfame / Best-way-to-wrap-up-your-jQuery-code-for-avoiding-conflicts.js
Created February 27, 2012 10:07
Best way to wrap up your jQuery code for avoiding conflicts
(function($){
// Regular jQuery code inside
$(document).ready(function(){
});
})(jQuery);
@ashfame
ashfame / svn-commands.sh
Created February 24, 2012 16:58
SVN commands
# Count no of files in repo
svn info -R --xml file:///path/to/rep | grep kind=\"file\"|wc -l
# SVN command to give commit authors list and save it in author-transform.txt
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt