Wednesday, October 18, 2017

Fix error "Invalid data set: 0" in Perl module GD::Graph

Error Message:
Invalid data set: 0 at D:\New\TOOL\graph.pl line 24.

Problem Code:

my @a1;
my @a2 = [-9,8,0,1,-2,-5,6,-4,3,7];

foreach my $i (1..10)
{
    push @a1, $i;
}

my @data = (
    @a1,
    @a2
);

Solution:

my @a1;
my @a2 = [-9,8,0,1,-2,-5,6,-4,3,7];

foreach my $i (1..10)
{
    push @a1, $i;
}

my @data = (
    [@a1],
    @a2
);

Fix error "Not a valid source data structure" in Perl module GD::Graph

Error Message:
Not a valid source data structure at D:\New\TOOL\graph.pl line 24.

Problem Code:
my $gd = $graph->plot(@data) or die $graph->error;

Solution:
my $gd = $graph->plot(\@data) or die $graph->error;

Complete working code:
#!/usr/bin/env perl
use strict;
use warnings;
use GD::Graph;
use GD::Graph::bars;

Monday, October 16, 2017

Windows 10 Fall Creators Update and Microsoft Launcher (Preview)

Fall Creators Update is the latest version of the Windows 10 Operating System by Microsoft. It is now available as beta release. To get this update you need to register your Windows 10 account as an Windows Insider. To join the program go to: https://insider.windows.com/en-us/

Windows 10 PC Version History:

Version Code Name Marketing Name
1507 Threshold 1
1511 Threshold 2 November Update
1607 Redstone 1 Anniversary Update
1703 Redstone 2 Creators Update
1709 Redstone 3 Fall Creators Update

Windows 10 version 1507, codenamed "Threshold 1", is the first release of Windows 10. It carries the build number 10.0.10240; while Microsoft has stated that there was no designated release to manufacturing (RTM) build of Windows 10, 10240 has been described as an RTM build by various media outlets.

Windows 10 Fall Creators Update, or Windows 10 version 1709, codenamed "Redstone 3", is the fourth major update to Windows 10 and the third of the four major updates planned under the Redstone codenames. The first preview was released to Insiders on April 7, 2017. It will be available generally on October 17, 2017.

Windows 10 version 1803, codenamed "Redstone 4", is the fifth major update to Windows 10 and the last of four major updates planned under the Redstone codenames. The first preview was released to Insiders on August 31, 2017. It will be available in early 2018.

Friday, October 06, 2017

Monoalphabetic Substitution Cipher in Python

import random

plain_text = "devharsh_T @ $01.2"
cipher_text = ''
decipher_text = ''

alphabets = [chr(a) for a in range(0,127)]
mappings = [chr(a) for a in range(0,127)]

random.shuffle(mappings)

print(alphabets)
print(mappings)

for i in range(len(plain_text)):
  for j in range(127):
    if(plain_text[i] == alphabets[j]):
      cipher_text += mappings[j]
 
print(plain_text)
print(cipher_text)

for i in range(len(cipher_text)):
  for j in range(127):
    if(cipher_text[i] == mappings[j]):
      decipher_text += alphabets[j]
     
print(decipher_text)

Wednesday, October 04, 2017

Monoalphabetic Substitution Cipher in C++

#include <iostream>
#include <string>
#include <ctime>
#include <chrono>
#include <thread>

int main()
{

  char plain[100] = "devharsh";
  char cipher[100];
 
  char alphabets[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  char mappings[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 
  alphabets[26] = '\0';
  mappings[26] = '\0';
 
  std::cout << alphabets << "\n";
  std::cout << mappings << "\n";
 
  for (int i=0; i<26; i++)
  { 
    srand((int)time(0));
    std::this_thread::sleep_for(std::chrono::milliseconds(300));
    int irand = rand() % 26;
    char temp = mappings[i];
    mappings[i] = mappings[irand];
    mappings[irand] = temp;
  }
 
  std::cout << alphabets << "\n";
  std::cout << mappings << "\n";
 
  for (int i=0; i<sizeof(plain) / sizeof(char); i++)
  {
      for (int j=0; j<26; j++)
      {
          if (plain[i] == alphabets[j])
          {
              cipher[i] = mappings[j];
          }
      }
  }
 
  std::cout << plain << "\n";
  std::cout << cipher << "\n";

}