Skip to content

Instantly share code, notes, and snippets.

View abhilash0001's full-sized avatar

Abhilash Shamsunder abhilash0001

View GitHub Profile
using System;
using System.Configuration;
namespace Custom.Helpers.Common
{
public static class Cache
{
private const string CacheSetting = "Cache.Duration";
private static System.Web.Caching.Cache _cache { get { return System.Web.HttpContext.Current.Cache; } }
private static int _cacheDuration { get; set; }
using System;
using System.Configuration;
using System.Web;
namespace Custom.Helpers.Common
{
public static class Cookie
{
private const string CookieSetting = "Cookie.Duration";
private const string CookieIsHttp = "Cookie.IsHttp";
@abhilash0001
abhilash0001 / gist:5ad7ee246eb1813a9af3
Created August 1, 2014 18:41
Cross domain ajax call - IE9+, Chome, Firefox, etc
/*********************************************************************************
Cross domain ajax call
IMPORTANT:
----------
If the webservice you are calling uses http, then the page you are calling the
function below should be http
If the webservice you are calling uses https, then the page you are calling the
@abhilash0001
abhilash0001 / gist:fff8b577125e05a21983
Last active August 29, 2015 14:03
AngularJS | Inject HTML
/*
How do I inject HTML?
The simplest and the most flexible way is to create a filter.
*/
angular.module('mfgapp')
.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
@abhilash0001
abhilash0001 / gist:670b9d1836b72e82fbcb
Created July 4, 2014 04:33
404: Unable to load angular.min.js.map or angular-animate.min.js.map resource
source map files basically turn minified code into its unminified version for debugging.
You can find the .map files here (https://code.angularjs.org/1.2.12/). Just add them into the same directory as the minified js files and it'll stop complaining. The reason they get fetched is the
/*
//@ sourceMappingURL=angular.min.js.map
*/
at the end of angular.min.js. If you don't want to add the .map files you can remove those lines and it'll stop the fetch attempt, but if you plan on debugging it's always good to keep the source maps linked.
@abhilash0001
abhilash0001 / gist:664a8b70c0c8f386bf25
Created June 26, 2014 04:15
Update wordpress urls in Database when you move from staging to production or any url change.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
/*********************************************
Breadcrumbs for wordpress without any
plugin. This also works for custom post
types.
You can refactor to make it more efficient. :)
Note: For your custom post types look at
line 47
**********************************************/
@abhilash0001
abhilash0001 / gist:ce1c9e155137d6087236
Created June 16, 2014 16:17
Wordpress | Custom post types
/* ==========================================================================
If you are a big fan of keeping your code base clean, you can place
the code below in the functions.php for custom posts single template
========================================================================== */
function get_story_post_type_template($single_template) {
global $post;
if ($post->post_type == 'story') {
$single_template = dirname( __FILE__ ) . '/page-templates/single-post-templates/single-story.php';
}
return $single_template;
@abhilash0001
abhilash0001 / gist:703f416d2a351f05e4d9
Created June 16, 2014 16:11
Wordpress | Blog re-write url
/* ==========================================================================
If you want to utilize post types for blog and want blog to be
under a parent page about Ex: "/about/blog/".
Place the code below in your functions.php and change the paths
accordingly
========================================================================== */
function filter_post_link($permalink, $post) {
if ($post->post_type != 'post')