Posts

Showing posts from 2017

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;                     button.setAttribute("data-clipboard-text",s);                     pre[i].appendChild(button);        } var clipboard = new Clipboard('.copy-button'); clipboard.on('success', function(e) {     console.info('Action:', e.action);     console.info('Text:', e.text);     console.info('Trigger:', e.trigg

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);             transition-timing-function: cubic-bezier(0.4,0.0,0.6,1);   }   .sidebar-container.sidebar-invisible {     -webkit-transform: translateX($(sidebar.width * -1));         -ms-

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

Call vs Start: Reasons why your batch script might not be writing output to file

Image
If you are calling another batch script from your source script you need to call it by preceding keywords Call or Start before the script name. But here also there is a catch: Start will open a new cmd window and execute command there and will not write the output in external text file if you have redirected it there: For example if you execute BatchScriptSource.bat it will not write anything in SomeTextFile.txt although it will be created. Contents of BatchScriptSource.bat start BatchScript.bat >> SomeTextFile.txt Contents of BatchScript.bat tasklist  Output Using Start: On the other hand Call will execute BatchScript.bat in the scope of same cmd session/window where BatchScriptSource.bat is being executed and will execute commands sequentially and write the output in SomeTextFile.txt as expected. Contents of BatchScriptSource.bat call BatchScript.bat >> SomeTextFile.txt Contents of BatchScript.bat tasklist Output Using Call:

Things you might not know unless you Automate your first task using task scheduler

Image
If you scheduled some script execution using task scheduler and its running fine only when you are logged in the system and failing when you are not logged in than keep reading ! Few months back I got moved to a new team to take on new challenges within my company where I had to pull some daily reports as a part of my new role apart from technical work. The process of pulling daily reports included logging into a SSL gateway,RDP a client domain server/jump server run few batch scripts there which in turn would produce few excel report files compressed within a single .rar file as output, ready to be copied to my local desktop, simple enough. As the batch scripts were to be executed at a particular time I chose windows task scheduler to do this work automatically for me instead of doing it manually as it was perfect fit for my need and moreover I dint had to write a single line of code or any other new script to serve my purpose,scheduling a task with task scheduler is easy, few

Installing OBS ? You better have DirectX installed on your system first

Image
Like always cutting the crap short: Quick Note: For those who didn't landed here searching for resolutions of error that they are facing during installation of OBS, OBS stands for Open Broadcaster Software which is free and open source software for video recording and live streaming.   For those who are looking to Resolve Errors: If you don't have DirectX installed on your computer system OBS will simply fail to install or may not work if by any chance it gets installed. The other piece of software that's required for proper functioning of OBS is Visual C++ Redistributable now the thing to note here is you might be already having this supporter installed on your system but just like like fate has many different ways to screw us and our plans so does Windows and installers but the good news is we do have different versions of Redistributable available like 2012 2013 and 2015 etc to fix our fate for free in this case ,so yes few more other simple installations are re

Adding code prettify to Blogger

Image
Cutting the crap short: You simply need  to add this line of code in your blogger/blogspot HTML template any where inside header tag <head>Add code Here</head> just before </body> tag this will not block page from loading and your site will stay as fast as it was without Syntax Higlighting: <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?skin=sunburst"></script> New url: <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?lang=css&skin=sunburst"></script> And then whenever you have post that involves somekind of code that needs to be pretty printed you wrap that code like shown below in HTML editor of your post editor dont forget to replace the Your code here with your actual code: <pre class="prettyprint linenums">Your code here</pre> If you want more theme options and styling you need to follow this