AutoMapper configuration in older and newer versions

Recently when I was looking for various architecture approached and tools sets, I saw this post which is very useful. But while I was going through the post I was getting error while implementing AutoMapper. I started getting below errors when I tried to configure AutoMapper as given on the link.

  • The type or namespace name ‘Profile’ could not be found (are you missing a using directive or an assembly reference?)
  • ‘ViewModelToDomainMappingProfile.ProfileName’: no suitable method found to override
  • ‘ViewModelToDomainMappingProfile.Configure()’: no suitable method found to override
  • ‘DomainToViewModelMappingProfile.Configure()’: no suitable method found to override
  • ‘Mapper’ does not contain a definition for ‘CreateMap’
  • ‘Mapper’ does not contain a definition for ‘CreateMap’

After some time I figured out the problem. Actually while following the tutorials I installed latest version (7.0.1 at that time) of AutoMapper from nuget while this tutorial was using 3.3.1 (that article was written sometime in 2015). Keep on reading

Javascript : Change current URL without redirecting the page

Sometimes, we need to change the url of current page without redirecting the page to the another url. Using javascript , we can achieve this very easily.

We can use the location object and its different properties to create our new url and using window object we can easily replace the current url with the new one.

Here is the example using which we can perform it :

<scrript type=”text/javascript”>

var clean_uri = location.protocol + “//” + location.host + location.pathname;

window.history.replaceState({}, document.title, clean_uri);

</script>

Thus, using above two line of code, we can change the url of any page without refreshing or redirecting it.

Password hash using PBKDF2 with HMAC SHA256/ SHA512 in .NET Framework 4.7 and before

Recently I got an requirement from one of my client to generate salted password hash using PBKDF2 and SHA-2 algorithms. But as everyone knows we only have SHA-1 available in .NET framework till now.

Because this was an client requirement so I have to accommodate in my project scope and to do this I got help from a nice guy who made this easy for me. While doing search on google I found this article from that guy. Keep on reading

[SOLVED] jQuery toggle not working for ajax loaded content

Some days ago while doing code for my client, I faced an issue with toggle function of jquery, and realized a fact about this function which I never knew earlier that jquery toggle function does not work for ajax loaded content.

I tried to make it work by using it in different ways but it did not work then after researching on google I came to know that toggle function will not work for content who is added dynamically in body tag. So, I had to find out the alternate of toggle function to get my work done. My code using toggle function was as which was working for content which was not shown through ajax :

$(‘.learn-more’).toggle(function() {
$(this).text(‘Learn less’);
$(‘.campaign-content’).addClass(‘open’);
}, function() {
$(this).text(‘Learn more’);
$(‘.campaign-content’).removeClass(‘open’);
});

So, to make it work for ajax loaded content also, I had to replace toggle function with simple click event and had to add few lines to make it work like toggle and reverse toggle events. So, my updated code is here, with jquery click method which will work same as above code written for toggle and reverse toggle events using jquery toggle function:

$(‘body’).on(‘click’,’.learn-more’,function(){
if($(‘.campaign-content’).hasClass(‘open’)){
$(this).text(‘Learn more’);
$(‘.campaign-content’).removeClass(‘open’);
}else{
$(this).text(‘Learn less’);
$(‘.campaign-content’).addClass(‘open’);
}
});

Here $(‘body’).on(‘click’,’.learn-more’,function(){}); is required because without specifying click event on body tag, the click event will not work for any class or id which is laded through ajax. To distinguish toggle and reverse toggle, I have used open class here, similarly you can use any class like active, inactive etc..

I hope it will help someone and will save someone’s day 🙂

[SOLVED] Rename wp-admin menus

We can easily rename the WP-admin menus labels by using two simple filter hooks i.e. init and admin_menu and assigning the new label in these filters.

To rename the Users menu, you will have to put following code in your theme’s functions.php file :

//Call init action hook
add_action( ‘init’, ‘_init’ );

//Call admin_menu action hook
function _init() {
add_action( ‘admin_menu’, array( $this, ‘create_menu’ ) );
}

/**
* Rename backend navigation.
*/
function create_menu() {
global $navigations;
global $menu;

$menu[70][0] = ‘Registered Users’;
}

Similarly, you can rename any wp-admin menu label by just providing index number of that menu.

If you want to rename submenu then you will have to provide submenu index also  as :

$menu[70][1] = ‘All Registered Users’;

Thus, by using above code, you can simply rename the Users label or other wp-admin menu’s labels easily.

 

addThis share not working for ajax loaded sharing icons

addThis is a robust solution for sharing content to different social platforms. It has plugins also which can be used for this purpose. addThis provides the html or we say toolbox which shows the social icons when we implement that to any page or post. We can also provide the url, title media or description of the page or post within the toolbox which are to be shared through social media icons.

Sometimes, we need to show this toolbox with sharing content through ajax. I we simply show the toolbox html through ajax, then the sharing icon will not display or will not work. To show and to make them work, we will have to reinitialize the toolbox in just single line which is :

addthis.toolbox(‘.addthis_toolbox’);  // Here ‘.addthis_toolbox’ is the the class applied on the toolbox html

Here is an example of showing addthis social icons through ajax request and reinitialize them :

jQuery.ajax({
type: ‘post’,
url: ajax_url,
data: data,
dataType: ‘json’,
success: function(response) {
jQuery(‘#sharing_div’).html(response); // response includes the html of addthis sharing icons
addthis.toolbox(‘.addthis_toolbox’);
}
});

Thus, we can simply reinitialize the addthis sharing toolbox in javascript.

OutSystems: How to set value to expressions

This article is about a new platform which I have explored and did certification. The name of the platform is OutSystems and it is a low code platform. Low code platform means we have to write a little or no code to develop an application and OutSystems is one those low code platform in the industry right now along with Mendix, Appian etc

This post if about a small problem which many of my colleague are facing while exploring OutSystems using its own official courses.

In OutSystems Mobile App Development course there is one class Creating Application Exercise where they have also explained use of expression on any screen and assigning values to it. But there is a little thing which many of the developers think is missing and because of this they face problem while assigning values to expression using mix of a string, method response or any entity value.

One of my friend asked me this problem:

Please see attached screenshot from “Creating Applications Exercise”
So I am stuck at Step 3 (b) on page # 13. I am able to set “GetAppName()” for the Expression but that is not correct.

How to set the Expression to “Hello from “ + GetAppName() ?
There is no screenshot for this step, perhaps it is too simple but I am not able to locate it.

Yes, this is a simple thing to do but because he was doing it first time so got confused. He was not sure how to call method in expression value so he just set  “Hello from ” in value not complete expression including GetAppName() method as shown in below screenshot.