Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

August 24, 2020

Microsoft Azure DevOps Server move or copy Project Source Code from one organization to another organization

Hi folks,

Today I will explain the process of moving the projects from one organization to another in Azure DevOps Server which includes the source repository code, history of commits, tags.


Pre-requisites

  • Git command line tool
  • ssh-keygen tool
  • Azure DevOps Project access


Environment Setup

  1. Create ssh key on your local PC
  2. Same user account on both the organization with required permissions (Admin)
  3. On Azure DevOps, to go user profile
  4. Add the generated SSH pub key of PC to Azure DevOps


Procedure in terminal/command prompt

1. git clone <old org project repo ssh url>

2. cd <project>

3. git branch -a

    a. git checkout <all branches one by one>

4. git fetch --tags

5. git remote rm origin

6. git remote add orgin <new org project repo ssh url>

7. git push origin --all

8. git push --tags


Hope you are able to move/copy the project source code which includes the history of commits and tags.

Please send your comments and feedback to psrdotcom@gmail.com


July 19, 2020

Simple free and open source generating QR code in your web page or blog with an API call

Hi folks,

Do you want to generate QR codes and display in your website or blog or for development.

You can call these API with the relevant data to get the QR code as an image format

    cht -> Chart Type = QR
    chl -> Chart Data = data
    choe -> Chart Encoding = UTF-8
    chs -> Chart Size = width x height
    size = width x heigth
    data = text data which we want to place in QR code

    
    Request Body    
{
    "frame_name": "bottom-frame",
    "qr_code_text": "https://www.qr-code-generator.com/",
    "image_format": "SVG",
    "frame_color": "#02bfff",
    "frame_text_color": "#ffffff",
    "frame_icon_name": "mobile",
    "frame_text": "Scan me",
    "marker_left_template": "version13",
    "marker_right_template": "version13",
    "marker_bottom_template": "version13"
    }

Please send your queries and feedback to psrdotcom@gmail.com

December 10, 2019

Go language install and configuration in Windows and Visual Studio Code as IDE

Hi folks,

Today I am going to describe you the best way to install and configure the Go language.

Download

From the Go language from its official web page https://golang.org/dl/

After installation, you would be able to program and run the code from any terminal.

What else?

Open your .go file in Visual Studio Code, it asks you something else. What was it?

"The "go-outline" command is not available. Run "go get -v github.com/ramya-rao-a/go-outline" to install."

What you need to do?

First, in Visual Studio Code set the the following in "settings.json" file.

"go.toolsGopath": "C:\\Go"

Note: If you are getting the following error, then click on "Install All"
The "go-outline" command is not available. Run "go get -v github.com/ramya-rao-a/go-outline" to install.

  • Get the location, where it is installing
  • Copy the bin and pkg folder contents to your Go installed folders.
  • Delete the folder which VS Code used to download the content.

That's all.. you should be able to code in Visual Studio Code as well without having 2 different go installed folders.

Happy Go coding!!

Please send your feedback and comments to psrdotcom@gmail.com

October 24, 2019

Markdown file convert/export to html, png, jpeg, pdf with images

Hi folks,

Today I will share about, how we can include the images in markdown file and export to pdf, html, png and jpeg formats.

You can do this with 2 Visual Studio Code extensions

Pre-requisites

Visual Studio Code with following MarkDown Extensions
  1. To place images
  2. To convert the markdown to pdf, html, png and jpeg formats
Install the above 2 Visual Studio Code extensions.

Insert an image

Create images folder and keep all your images (Optional, but easy to maintain)
Syntax: ![](images/imagename.extension)
Usages: ![](images/abc.png)

By now, your image is part of your file.

Preview your file

Open Command Palette (View -> Command Palette OR Type F1 OR Ctrl+Shift+p)
Type "Markdown: Open Preview" OR Ctrl+Shift+v keyboard shotcut

Export Markdown

Open Command Palette (View -> Command Palette OR Type F1 OR Ctrl+Shift+p)
Type export and select below
  • markdown-pdf: Export (pdf)
  • markdown-pdf: Export (html)
  • markdown-pdf: Export (png)
  • markdown-pdf: Export (jpeg)
  • markdown-pdf: Export (all: pdf, html, png, jpeg)

Change Markdown conversion settings

  1. Select File > Preferences > UserSettings or Workspace Settings
  2. Find markdown-pdf settings in the Default Settings
  3. Copy markdown-pdf.* settings
  4. Paste to the settings.json, and change the value
Hope this blog is useful to insert images in your markdown file and export to supported formats.

Please send your valuable feedback and comments to psrdotcom@gmail.com

November 01, 2018

Microsoft Visual Studio Code with Debugger for Chrome for Static Website Pages

Hi all,

Have you used the Microsoft's free VS Code editor for you web development. I think, you should try it.

Today I'll discuss about how to debug from the VS Code without placing breakpoints on Chrome browser.

Pre-requisites


  1. VS Code should be installed
  2. Debugger for Chrome extension in VS Code


Configuring the debugger

  • Once you open your website in the VS Code
  • In the activity bar, you will find the debugger icon OR you can use the keyboard shortcut Ctrl+Shift+D
  • Now, we will "Add Configuration" to our project
  • On top of the debug sidebar, you will find an option "Add Configuration"
  • Click on "Add Configuration"
  • It will prompt you to select out of box provided options like "Chrome, NodeJS"
  • Choose Chrome
  • Now, launch.json file will be created
  • Configure the launch.json file by specifying URL with port number
  • Since, our project is of static webpages type, instead of webRoot, we will use "file"


Here is the sample launch.json file

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome for my website",
"url": "http://localhost:3001",
"file": "${workspaceFolder}/index.html"
}
]
}

Debug

  • Click on the "Start Debugging" button OR press F5
  • A new chrome window with debugging enabled will be launched
  • Place your breakpoints in VS Code, just by clicking left to the line number in the editor
  • Perform the action and your debug will be hit
  • Note: You can add conditional debugging by editing the break point


Happy debugging.

Please send your review and comments to psrdotcom@gmail.com

May 30, 2017

Compress folders/files and create .tar.gz (Tar archive with GunZip Compression) and .zip (ZIP compression) file in Java

Hi friends,

Today I will explain how easily we can compress files and folders in java.

I have used a third part library which so simple to use.

Download the .jar from the following URL
https://rauschig.org/jarchivelib/download.html

Now, create a java class and create .tar.gz and .zip files.

Sample source code

package gunziptest;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.rauschig.jarchivelib.ArchiveFormat;
import org.rauschig.jarchivelib.Archiver;
import org.rauschig.jarchivelib.ArchiverFactory;
import org.rauschig.jarchivelib.CompressionType;

/**
 *
 * @author psrdotcom
 */
public class GunZipTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // Archive file name
        String archiveName = "archive";
        // test is destination folder
        File destination = new File("test");
        // source folder has files and sub-folders
        File archive = null;
        
        // zip compression
        Archiver archiver = ArchiverFactory.createArchiver(ArchiveFormat.ZIP);
        try {
            archive = archiver.create(archiveName, destination, source);
            if(archive != null && archive.isFile()) {
                System.out.println("gunziptest.GunZipTest.main()" + "zip file created");
            }
        } catch (IOException ex) {
            Logger.getLogger(GunZipTest.class.getName()).log(Level.SEVERE, null, ex);
        }

        // tar.gz compression
        archiver = ArchiverFactory.createArchiver(ArchiveFormat.TAR, CompressionType.GZIP);
        try {
            archive = archiver.create(archiveName, destination, source);
            if(archive != null && archive.isFile()) {
                System.out.println("gunziptest.GunZipTest.main()" + "zip file created");
            }
        } catch (IOException ex) {
            Logger.getLogger(GunZipTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Hope, you will find this useful.

Please send your review and feedback to psrdotcom@gmail.com

December 19, 2014

Reverse Engineering .apk file (or) Getting Java source code from .apk by extracting

Hi friends,

Today we are going to see how the .apk can be reverse engineered to see the original source code

Procedure

  1. Get the .apk file (Here I'm taking example apk called psr.apk)
  2. Rename the extention from psr.apk to psr.zip file
  3. Extract the psr.zip file
  4. It will create folder named "psr" and contents will be inside that
  5. Download the tool "dex2jar" from the official link
  6. Extract the downloaded "dex2jar" zip
  7. Navigate to the "dex2jar" extracted directory
  8. Execute the following command
    • ./d2j-dex2jar.sh psr/classes.dex
  9. Now it will generate classes-dex2jar.jar file
  10. Extract the jar file, it will create "classes-dex2jar" folder
  11. Now, open you "intelliJ IDEA"
    • Install "Java Decompiler IntelliJ Plugin" in "intelliJ IDEA"
    • In IDE, click "File->Open"
    • Select the "classes-dex2jar" folder path
  12. Now, click on any of the .class file, then you should be able to see the original java source code of it

Isn't it awesome guys :)

Keep enjoying the coding :)

Please send your feedback and comments to psrdotcom@gmail.com

January 05, 2013

Eclipse Java Scrapbook: Run, Debug, Test Code Expressions and Statements Without Running Entire Project

Hi friends,

A very useful utility for developers who are using eclipse as their IDE is Java Scrapbook.

What is scrapbook?

Sometimes, you might think like running a statement or expression or loop without running the entire code or project. You want to try something without disturbing the existing code.

Scrapbook answers the above and lot more.

Scrapbook can be used to inspect, execute, debug your statements, expressions, loops and etc.

Creating Eclipse IDE

New -> Java -> Java Run/Debug -> Scrapbook Page

Inspecting Snippet

To inspect an snippet like 2+3, Just type 2+3 and Click on "Run->Inspect" as per your requirement. It will display the result in a pop-up.

Execute Statements

If you want to try some statements, you can execute it by performing "Run->Execute"

Debug Statements

You can put breakpoint and debug your code.

I liked it very much because we no need to run the entire project to test/try a sample code.

Hope all the developers will like this feature.

Note: Please send your feedback to psrdotcom@gmail.com

April 29, 2012

Huffman Code in C/C++ with String as Node

Hi everyone,

I have copied someone's code and modified. But Since, the author has put the code as open source, I have done that for my friend.

Here it goes, Huffman code in C/C++

Source Code:
#include<conio.h>
#include<string.h>
#include<math.h>
#include<iostream.h>
#include<stdlib.h>

#define ARRAY_SIZE 20
#define MAX_NAME_LEN 25

int g,h,p,y,n;
char m[ARRAY_SIZE],b[ARRAY_SIZE][2],re;

int alpha = 65;

char name[ARRAY_SIZE][MAX_NAME_LEN];
int i=0,j=0,k=0;

/*
Perfoming operations
*/

//Tree Structure
struct tree
{
char a[20];
int s;
struct tree *left,*right;
}*root=NULL,*tt[20]={NULL},*temp,*temp2,*t2,*ri,*le;


// Queur Structure
struct pqu
{
int info;
char a[20];
struct pqu *ptr;
}*front=NULL,*t,*par,*t1,*p1,*p2;

// Pointer to queue
struct pqu* fp(int info)
{
struct pqu *p=NULL;
for(t1=front;t1->info<info&&t1!=NULL;t1=t1->ptr)
{
p=t1;
}
return (p);

}

//PUSH operation
void enqu(char a[20],int p)
{
t=(struct pqu*)malloc(sizeof(struct pqu));
strcpy(t->a,a);
t->info=p;
t->ptr=NULL;
if(front==NULL)
{
front=t;
}
else
{
par=fp(p);
if(par==NULL)
{
t->ptr=front;
front=t;
}
else
{
t->ptr=par->ptr;
par->ptr=t;
}
}
}

// POP operation
struct pqu* dequ()
{
t1=front;
front=front->ptr;
return t1;
}

//Get Info of a leaf
void info(char c[2])
{
int m=0,i;
temp2=root;
while(strcmp(c,temp2->a)!=0)
{
t2=temp2->left;
for(i=0;i<strlen(t2->a);i++)
{
if(t2->a[i]==c[0])
{
temp2=temp2->left;
m=1;
cout<<”0&”;
break;
}
}
if(m!=1)
{
temp2=temp2->right;
cout<<&”1&”;
}
m=0;
}
}

// Insert Operation
void insert()
{
char a1[20],b1[20],v1[20];
int i,j,z=0,l;
while(front!=NULL)
{
p1=dequ();
strcpy(a1,p1->a);
l=p1->info;
p2=dequ();
if(p2==NULL)
break;
strcpy(b1,p2->a);
strcpy(v1,a1);
temp=(struct tree*)malloc(sizeof(struct tree));
strcpy(temp->a,strcat(v1,b1));
temp->s=l+p2->info;
temp->left=NULL;
temp->right=NULL;
temp2=temp;
root=temp;
for(i=0;i<z;)
{
if(strcmp(tt[i]->a,a1)==0)
{
temp->left=tt[i];
for(l=i;l<z;l++)
{
tt[l]=tt[l+1];
}
i=0;
continue;
}
else if(strcmp(tt[i]->a,b1)==0)
{
temp->right=tt[i];
for(l=i;l<z;l++)
{
tt[l]=tt[l+1];
}
i=0;
continue;
}
i++;
}
if(temp->left==NULL)
{
le=(struct tree*)malloc(sizeof(struct tree));
strcpy(le->a,a1);
le->left=NULL;
le->right=NULL;
temp2->left=le;
}
if(temp->right==NULL)
{
ri=(struct tree*)malloc(sizeof(struct tree));
strcpy(ri->a,b1);
ri->left=NULL;
ri->right=NULL;
temp2->right=ri;
}
if(front!=NULL)
enqu(temp2->a,temp2->s);
tt[z++]=temp2;
}
}

//Display Tree
void disp(struct tree *rt)
{
if(rt!=NULL)
{
disp(rt->left);
//cout<<””<<rt->a;disp(rt->right);
}
}

//Display Name
void displayname(int idx)
{
cout<<name[idx]<<”: ”;
}

/*
End of operations
*/


//Main Method

int main()
{
while(1)
{
//Clear Screen
clrscr();

cout<<”Enter the total no of leafs : ”;
cin>>n;


for(i=0;i<n;i++,alpha++)
{
cout<<”Enter Name: ”;
cin>>name[i];

//itoa(alpha,m,10);
//strcpy(m,(char*)alpha[i]);
*m=(char)alpha; //Assigning Local Values
strcpy(b[i],m);

cout<<”Enter frequency for ”<<name[i]<<” : ”;
cin>>g;

//Enque to the list
enqu(m,g);

} //Repeat till all the leafs data entered

insert(); // Form the tree
disp(root); // Display the codeword of leaf from root


for(i=0;i<n;i++)
{
displayname(i);
info(b[i]);
cout<<”n”;
}

cout<<”nDo You Want To Continue Y or N: ”;
cin>>re;
clrscr();
if(re=='y'||re=='Y')
continue;
else
break; //exit(0);
}

return 0;
}//end of while

Output:

I am also making this as an open source code. Anyone can edit, share, re-distribute the code.

For further queries, please mail to psrdotcom@gmail.com

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com