Posts

Adding Home Older Newer Post Buttons in new Blogger templates such as Contempo

Image
Requirement: Add Home, Older, Newer Post Buttons in new Blogger templates such as Contempo. Solution: Hi for this jump to Blog widget in HTML editor of your template and find and replace code in includables with respective id's with the ones given below also change the order of buttons as shown below in postPagination includable as per your needs. Code given below shows button in this order   Older Posts Home Newer Posts Demo: Can be seen by clicking here and scrolling to end of page. Screenshot: Note: First page will display only Older posts button as there is nothing to go back when we are on landing or home page and the last page will display Previous posts button and the Home button as there is nothing left to go forward. Displays buttons in order provided here in frontend ,ID to search postPagination: <b:includable id='postPagination'> <div class='blog-pager container' id='blog-pager'> <b:include cond='data:new...

Converting blogger HTML tables into Smart Responsive tables using CSS

Image
Requirement: Make all HTML Tables in Blogspot responsive ,pretty & a bit smarter. How: Its 2 step process. Add CSS for styling to template Modify your Table Structure accordingly. Here is the  link   of the post having table with formatting provided below to see things in action, try changing size of browser to see how it adapts to various screen sizes. Here are some screenshots as well: On Desktop:  On Mobile/Tablets/Phones: Steps: 1: Add the following CSS code in template from HTML editor: <style> table { border: 1px solid #ccc; border-collapse: collapse; margin: 0; padding: 0; width: 100%; table-layout: fixed; } table caption { font-size: 1.5em; margin: .5em 0 .75em; } table tr { background-color: white; border: 1px solid #ddd; padding: .35em; } table th, table td { padding: .625em; text-align: center; } table th { font-size: .85em; letter-spacing: .1em; text-transform: uppercase; backgroun...

Essential Trace Flags to enable at SQL Server Services startup

Image
 List of trace flags to enable on SQL server service startup: Server Name Trace Flag Status Global Session PRD-MSSQL01C 1222 1 1 0 PRD-MSSQL01C 1224 1 1 0 PRD-MSSQL01C 4136 1 1 0 Reason:  4136  will help in preventing parameter sniffing on sql server and in turn will result in query optimizer to create optimized plans for same queries having different parameters which will result in better performance.  Note: Please ensure that you thoroughly test this option, before rolling it into a production environment. Scope: Global or session 1224 d isables lock escalation based on the number of locks. However, memory pressure can still activate lock escalation. This helps avoid "out-of-locks" errors when many locks are being used. Scope:  Global or session 1222 helps in detecting deadlocks r eturns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any X...

Checklist: Before applying for adsense

Image
Before applying for adsense below things has to be taken care of Remove reference to all other old sites and turn of profile about widgets Create a yourname@yoursite.com email Create a google analytics account link it to your site Create a menu structure Fill ALT and Description tags for all posts and images No follow external links Place menu optimally and check its working fine and visible in all screen sizes See available adsence widgets still has proper visibility after template modifications Correct all grammatical mistakes Create About, Contact and Privacy pages Create few more Posts Work on SEO a bit for few days Add links to Youtube channel

Solution: More Posts & Posts Links not working with Adsense Anchor ads on Touch screen mobiles in blogger

Image
Problem Statement: Whenever anchor ads are loading in mobile More Posts link is becoming dead and also other links such as Title of posts in feed along with the Keep Reading link is becoming unresponsive to touch and thus users are unable to browse site properly. So coming straight to solution: I have seen this happening only when something is having z-index more than the other elements on the page in this case when anchor ads were loading it seems like the z-index for the anchor ads was overriding the z-index of page elements itself leaving them unresponsive to touch though they are working completely fine on clicks over computer system ,so to fix this I added a small piece of CSS style="z-index:1000!important;"  to the element or More Posts link so that in the page DOM layer it comes just at place where both Anchor ads and More Posts remains clickable without clashing with each other. Please find the screenshots below for your reference to find where the changes ...

Fixed: Wordpress Visual Post editor not working issue

Image
Hi everyone as always I will cut the crap and come straight to point. I got the task to fix a site and for that I created a new user from backend using phpmyadmin using the following command as the owner of site had forgotten the password for wp-admin: INSERT INTO `wpdatabasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('2', 'Shivam', MD5('demopass'), 'Shivam', 'test@yourdomain.com', 'http://www.test.com/', '2019-05-16 00:00:00', '', '0', 'Shivam'); INSERT INTO `wpdatabasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '2', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'); INSERT INTO `wpdatabasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '2'...

Powershell script to automatically send HTML emails using gmail smtp

Image
Hi please find the script/code below which can be used (as a example  use case) for sending automated reminders for filling time-sheets  to all employees on every Friday(can be any day depending on when you schedule it to run using windows task scheduler as per your requirements) using gmail gsuite or any other email providers: Things Required: SMTP outgoing port(587) allowed through firewalls No-reply email which will be used for sending emails Application password (as gmail blocks sending emails from scripts if direct credentials(username & normal password) are used and sends warning alerts and notifications to owner and eventually blocks the account if not rectified thus application password needs to be created and used to prevent that from happening,steps for creating same are given below) Server which runs 24x7 where we will place and schedule our scripts to run at specific time.(You can use your local PC systems and execute script manually by double clicking ...

Script to delete the files older then 2 days from All Available Drives On Servers:\AnyDirectory

Image
Script below can be used to delete the files which are older then 2 days from All Available Drives On Servers:\AnyDirectory. If you want to filter files with some particular extension please add the following handle to the script : /m (searchmask) Searches files according to the specified search mask. The default search mask is *.\*. More information about parameters and variables available can be found here @ECHO off Rem=================================================================================================================== Rem AUTHOR: SHIVAM KUMAR | https://www.linkedin.com/in/shivamkumars Rem VERSION: 1.0 Rem DESCRIPTION: Script to delete the files which are older then 2 days from "All_Available_Drives_On_Servers:\AnyDirectory" directory Rem How to use: Select the servers from hpsa and right click and run script,no user input is required. Rem Disclaimer: The script has to be run on proper timings after the backup or what ever patching activity else you m...

Adding a new table to Replication in MSSQL Server without reinitializing the Snapshot

Image
There are some prerequisites for Tables to be a part of replication: It should have a PRIMARY KEY It should have IDENTITY NOT FOR REPLICATION NOT NULL: If prerequisites are not met for Primary key you will see the following error: Msg 14088, Level 16, State 1, Procedure sp_MSrepl_addarticle, Line 1539 [Batch Start Line 0] The table '[dbo].[T_YourTableNameHere]' must have a primary key to be published using the transaction-based method. Though NOT FOR REPLICATION FOR IDENTITY will not throw any error during the time you are adding the table to replication but it will start throwing errors once you will start inserting rows or data into the table and I am guessing you must have heard this earlier "prevention is better than cure" . Alright once prerequisites has been taken care of  this tasks can be accomplished using the following steps : Create table in Publisher Node. Create table in all Subscriber Nodes. Use sp_addarticle to add and publish the new ...

T-Sql Script for Automating Replication Generation for all Stored Procedures in a SQL Server Database

Image
This involves following steps: Creating stored procedure named Create_Replication_SP using the code provided in this post. Please find the T-sql script below that can be used to create,configure and run replication for all stored procedures in a database automatically.  Once stored procedure is in place all you have to do is provide the name of the database as the parameter as shown in example below: Use NameOfDatabasewhereSpIsCreated GO EXEC [Create_Replication_SP] @Database_Name='NameOfDatabaseHere' This will generate and Print a script in return in messages tab in SSMS.  Copy the generated script and paste it in new query window and execute it and wait for its completion, progress gets tracked in Messages tab in Output window.  What script does: This creates Publication with nomenclature DatabaseName_SP or if you want a custom name you can pass the parameter @Publication_Name along with @DatabaseName (should be under 20 characters).  Creates a snap...

Adding Contact form within Blogger Contact Page

Image
Let me be quick on this one : This is 2 step process I am using Contempo template but things are pretty same for any blogger theme. Getting the contact form widget: Add a contact form gadget to sidebar from layout section to get the contact form and then hide it from sidebar by using CSS: style="Display:None;"  To do that jump to Contact form widget from Theme>> HTML Editor>>contact form widget and expand  <b:includable id='content'>  Find this:  <div class='contact-form-widget'> and replace it with this:  <div class='contact-form-widget' style='display:none!important'> Moving the contact form to Page: Create a new contact page from pages section switch to HTML editor add the following html between the div tags already present there and publish it. Note: Below code is coming from expanded content section of contact form widget from theme editor so in case you are facing some issues that's the place yo...

How to make your own online Code Compiler Platform in 30 minutes

Image
For this Demo Tute we will be showcasing just Python : Install Node.js from https://nodejs.org/en/ this will also install NPM on your Server\System. NPM will be used to install various packages given below to make this work: Install compileX using command given below on cmd: npm i compilex Install express using command given below on cmd: npm i express Install body-parser using the command given below on cmd: npm i body-parser Install Python on your Server\System as this will be used by our web app to execute code. Set Python in Path variable so that you can execute it from anywhere from cmd without traversing directories again and again. Add code given below to notepad and save it as TestPython.js in some directory. var express = require('express'); var path = require('path'); var app = express(); var bodyParser = require('body-parser'); app.use(bodyParser.urlencoded({     extended: true   })); app.use(bodyParser.json()); //compileX var compiler ...

How to Automatically MSTSC or RDP into Windows Server without entering Password again & again

Image
Like always will come directly to point: Disclaimer: This saves password in clear text in batch file so think before using it on a shared system.If this doesn't bothers you and its really necessary as your connection is too fluctuating go ahead and read below how you can do it. This is a 2 part process : Create batch file with all the commands given below and save it as NameOfBatchScript.bat this name is used in VBScript so make sure you replace it accordingly. Create a VBScript file with commands  given below to load the batch file we created in above step without showing the mstsc yes no prompts, save this file with any name you like(May be your Jump Server Name is best Choice for its name in case you have multiple due to multiple clients) but make sure to save it with extension  as .VBS Note: Replace the DomainName, Username & Password accordingly also IP with Server name\IP of server you are trying to connect if in same domain or with its FQDN if not in b...

Query to Expand and List All logins within a SQL Server Group

Image
This query will get the details of user logins with in Active directory security group in expanded format which is not available by default in SSMS, this will iterate over all the user logins under Security section and expand and list the users within the group if there are any along with all other logins: For example DBA team has 10 members who are part of Group Name DBA_GROUP and this Group is added in SQL Server logins so it will list the members with in DBA_GROUP as well (like DOMAIN\DBA1 DOMAIN\DBA2 and so on )instead of just listing DBA_GROUP. SET NOCOUNT ON CREATE TABLE ##TEMPHOLDUSERS       (        AccountName NVARCHAR(MAX),        AccoutnType NVARCHAR(MAX),        Privilege NVARCHAR(MAX),        MappedLoginName NVARCHAR(MAX),        PermissionPath NVARCHAR(MAX)       ) DEC...

Redirecting all old url to home page or any other page in blogger using script

Image
Adding a 301 redirect for every url which has year older then the value we are setting in our script: So why this was needed ? Recently I found in google search console that lot of Page not found errors are triggering for my site and when I looked at the links it was clear that the errors are because the domain was owned by someone else before I got it and google crawlers were still trying to find posts and pages which were published by previous owner. Although there is a option to create a redirect for links in blogger dashboard but doing that for every single url each and every time was too much of work and also this was a blind game as we don't know for which url the error will trigger next until it was being logged in google search console: So here is quick summary for what I did followed by script and the Long explanations. Quick Summary: Get current Url user is visiting on my site>Extract Year part from it>If YearFromUrl(is less then)<YearIStartedWritingP...

SQL Server SSMS Bug: Scripting Delete action to new query window for Maintenance plans is deleting the maintenance plans without even executing the script leaving jobs behind which throws errors during manual delete

Image
SQL Server version: Microsoft SQL Server 2014 (SP2) (KB3171021) - 12.0.5000.0 (X64) Tested using SSMS 17 and SSMS 12 Scripting Delete action to new query window for Maintenance plans is deleting the maintenance plans without actually executing the script: Steps to reproduce: Create a maintenance plan using maintenance plan wizard This creates maintenance plan under path : Server or Instance Name>Management>Maintenance Plans along with a corresponding job under Sql server agent when viewed from SSMS Now right click on the Maintenance plan that gets created from step 1 in location specified in step 2 above and click delete But instead of clicking OK use the script button on top of window and select "script action to new query window" and then click CANCEL in the same window from where we just selected script action. So we just scripted the action and haven't actually deleted the plan nor by clicking OK nor by executing the script that gets created in new w...

Adding copy to clipboard button to every google code prettify pre blocks in blogger

Image
It's a 2 part process: The script part to find all the pre blocks having code in it and append a copy button to it dynamically. The style part to place our copy button at the specified location(on top right of every code block in this case) The script part: <script> var pre = document.getElementsByTagName('pre'); for (var i = 0; i < pre.length; i++) {             var button = document.createElement('button');                     button.className = 'copy-button';                     button.textContent = 'Copy';                     var s = pre[i].innerText;             ...

Enabling fixed Sidebar for blogger Contempo template for screen sizes smaller than 1440px

Image
Here is how to do it : Add this code in your blogger template(where to add this code is mentioned before 2nd code snippet of this post) ,now the value 1300px is the screen size for which I want the sidebar to be always visible for, you can reduce this value as you like, but be aware that reducing this value to much smaller digit will result in showing the overlapped sidebar instead of content body for your blog readers who are using much smaller screen devices such as mobiles which you might not want to happen so be wise : @media screen and (max-width: 1300px) {   .sidebar-container {     bottom: 0;     position: fixed;     top: 0;   }   .sidebar-container {     left: 0;     right: auto;   }   .sidebar-container.sidebar-invisible {     -webkit-transition-timing-function: cubic-bezier(0.4,0.0,0.6,1);             tra...

Connecting Microsoft SQL Server using PHP

Image
Throwing Steps Right away without wasting much time : 3 things you need to have: WAMP/XAMPP installed on your system to run PHP. SQL Server for creating and connecting to Databases etc. PHP Drivers : For bridging SQL Server and PHP. Latest version of PHP Drivers can be download from this Download link which now supports PHP version 7.x. Steps for installing PHP drivers: The file that you will download is a nothing but a zip containing some dll files which are nothing but PHP extensions. Find the PHP extension folder for the version you are using and place the files inside that folder. Next open the Php.ini files for the version in use and add the initialization for the dll/plugins files that you just placed in extensions folder cos without initialization those files are good for nothing. Restart the wamp services. Goto Php extension from wamp menu and select the options which are having the same name as those files. This completes the installation part and now we ar...