My wp-ShowGithubFile plugin is accepted by WordPress today!

Though I wrote the plugin initially for personal use, now the same is available for you to use in your WordPress sites.

Link: https://wordpress.org/plugins/wp-showgithubfile/

You can either download it from the directory, or install directly within your WordPress installation. Here is a live demo of the plugin:

001 package com.company;
002
003 import java.util.Arrays;
004
005 public class Main {
006
007     public static void main(String[] args) {
008
009         // New Customer wants to buy a bottle
010         Customer customer = new Customer();
011
012         // Customer Registration
013         customer.RegisterMe("+919999999999"PhoneType.APP ); // App or SMS?
014
015         // Assuming Registration successful
016
017         // Customer requests the token using a mobile app, or by sending SMS
018         String CustomerToken =  customer.giveMeAToken("695000"); // Pin code
019
020         if (CustomerToken != null) {
021             //  Assuming Customer gets the token and he goes to the Outlet
022         } else {
023             // Seems there are no slots available. Try again later.
024             return;
025         }
026
027
028         // At the Outlet, sales guy is scanning the token
029         Boolean OutletVerification = new Outlet().isTheTokenShownByCustomerValid(CustomerToken);
030
031         if (OutletVerification) {
032             // Assuming the validation is success
033             System.out.println("Customer says: Wow, I got the bottle!");
034         } else {
035             System.out.println("Sales guy says: Get lost!");
036         }
037     }
038
039     public enum PhoneType APPSMS };
040
041     private static class VQServer {
042         // Database
043         public String[] tokenDB = { "A""B","C","D","E" };
044         public String[] Outlets = {"Outlet1""Outlet2""Outlet3"};
045
046         public void registerCustomer(String phoneNumberPhoneType phonetype) {
047             // Register customer
048
049         }
050         public String requestNewTokenByCustomer(String pinCode) {
051             // Logic for - Token generation logic
052             // Logic for - Find nearest outlet using pinCode
053
054             // Send token by SMS if PhoneType is SMS
055
056             return "C"// Sample token
057         }
058
059         public Boolean validateTokenByOutlet(String token) {
060             return Arrays.asList(tokenDB).contains(token); // Validate
061         }
062     };
063
064     static VQServer vqServer = new VQServer();
065
066     private static class Customer {
067
068         public String giveMeAToken(String pinCode) {
069             return vqServer.requestNewTokenByCustomer(pinCode);
070         }
071         public void RegisterMe(String phoneNumberPhoneType phonetype) {
072             // Customer Registration
073             vqServer.registerCustomer(phoneNumberphonetype);
074         }
075     }
076     private static class Outlet {
077         public Boolean isTheTokenShownByCustomerValid(String token) {
078             return vqServer.validateTokenByOutlet(token);
079         }
080     }
081 }

View in GitHub | Made with wp-showgithubfile plugin

Clone/Copy SQL Server Database with timestamp in name

This script works on Azure SQL Database also.

 DECLARE @cmd nvarchar(255) SET @cmd = N'CREATE DATABASE ' + CONCAT('MyDB_', REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(16), GETDATE(), 120), '-', ''),':',''),' ','_')) + ' AS COPY OF MyDB' EXECUTE sp_executesql @cmd 

Enable Windows Explorer previews for custom file types

Coders, have you ever wished if you get preview of source code while you are in Windows Explorer? Yes it is possible. You might know already that there is a “Preview Pane” feature present. According to a file’s Content Type the preview will be shown at the right side of the window. Common formats supported are – .txt, .mp4, .jpg etc.

image

BUT, most of the developer’s files like .cs, .php, .config, .log files are not supported by default and you will be presented with a message “No preview Available” like this:

image

How to enable preview for a specific filetype?

Step 1: Go to Regedit. Expand the node HKEY_CLASSES_ROOT

Step 2: look for your required extension, eg: .php (If the extension is not already present, then create a key)

Step 3: Add a string value PerceivedType and set its Data to text

Voila!, your file preview is ready!

image