PostgreSQL Run on Docker with Create User and Database

1.
docker pull postgres
2

docker run --name postgresdb -v /home/sudipto/Development/PostgresDb:/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=root -d postgres
3.

 docker inspect postgresdb

4.
docker exec -it postgresdb bash

5.
psql -U postgres -W

6.

CREATE USER user11 SUPERUSER PASSWORD '69use420';
7.
CREATE DATABASE pguser11db1;
8.
GRANT ALL PRIVILEGES ON DATABASE pguser11db1 TO user11; 
 


 


 
 

install & Remove nodeJs &npm at Ubuntu

Remove NodeJs & npm

cd /usr/local
sudo rm -r bin/node bin/npm include/node lib/node_modules share/man/man/node.1
cd
rm -r .npm
OR
sudo apt-get remove nodejs
sudo apt-get remove npm

Install Latest Version of NodeJs & npm

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
node --version

Copy a whole website via Linux command

wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains devitems.com --no-parent devitems.com/html/intensy-preview/


------------------------Or------------------------------------


wget --limit-rate=200k --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://themesground.com/Superb/


SingleTon Design Pattern Java

Create a Java Application Project.

Post this 2 class file in root.

-------------File MainClass.java-----------------------------------------------------------------------------
package singleton;

public class MainClass {

    public static void main(String[] args) {

        MathHelper tmp = MathHelper.getInstance(12);
        MathHelper tmp2 = MathHelper.getInstance(14);
        MathHelper tmp3 = MathHelper.getInstance(16);

        tmp.demoMethod();
        tmp2.demoMethod();
        tmp3.demoMethod();
    }
}
------------------------------------------------------------------------------------------


-------------File MathHelper.java-----------------------------------------------------------------------------
package singleton;

public class MathHelper {

    private static int sNumber;
    private static MathHelper singleton;
    /* A private Constructor prevents any other * class from instantiating. */

    private MathHelper() {
    }

    /* Static 'instance' method */
    public static MathHelper getInstance(int number) {
        if (singleton == null) {
            sNumber = number;
            singleton = new MathHelper();
        }
        return singleton;
    }
    /* Other methods protected by singleton-ness */

    public static void demoMethod() {
        System.out.println("DemoMethod for singleton: Number= " + sNumber);
    }
}
------------------------------------------------------------------------------------------


Run MainClass.java file.

You got result
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12

Same result for every time.


It's can update private static variable 'sNumber' only first time by method ‘getInstance()’. Because then no object create yet. Only first time object is null. Then it’s creating a new object by considering current object is null and return it. At that time 'sNumber' able to update its value to 12.

After creating first time object, it will never able to create new object and can't update the 'sNumber'. It's return the same old object every time. And we got 12 , even we push new value when we get new object.


Ubuntu Create Launcher

create a file name with [android-studio.desktop]

[-----------------------------------------------------------------------------------------------------------------------]
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec=/home/w3e/Programs/android-studio/bin/studio.sh
Icon=/home/w3e/Programs/android-studio/bin/studio.png
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
Name[en_GB]=android-studio.desktop

[-----------------------------------------------------------------------------------------------------------------------]

Dont forget to make the file executable (chmod +x android-studio.desktop).

Complexity Reducing of Java Code

public boolean isAllowedFileExtension(String extension) {
    boolean isSupported = false;
    try {

        ///Instead of this code block, use following block          
                if (extension.contains("pdf") 
                || extension.contains("doc")
                || extension.contains("docx")
                || extension.contains("ppt")
                || extension.contains("pptx") 
                || extension.contains("apk")
                || extension.contains("zip")
                || extension.contains("rar")) 
        {
            isSupported = true;
        }

        ///Use this code block, instead of above code block         
        String[] fieldsToInclude = {"pdf", "doc", "docx","ppt"};
         
        for (int i = 0; i < fieldsToInclude.length; i++) {
            if (extension.contains(fieldsToInclude[i]))
                isSupported = true;
            break;
        }

    } catch (Exception e) {
        Log.e("isAllowedFile", e.toString());
    }
    return isSupported;
}

Optional Parameters Sequence Interchange

///Calling Class
    public class Student
    {
        public void PrintList()
        {
            var wg = new WebGrid();
            wg.Print(new List<Student>(), 1, 100, "Name", "ASC");
        }
    }
///Called Class
    public class WebGrid
    {
        //Main Method
        internal void Print(List<Student> list, int page, int size, string sortBy, string sortDirection)
        {
            //No Error
            throw new NotImplementedException();
        }

        //You Want
        internal void Print(List<Student> list, int page, int size, string sortBy = "Name", string sortDirection)
        {
            //Error , Optional parameters must appear after all required parameters
            throw new NotImplementedException();
        }
        //Your Solution
        internal void Print(List<Student> list, int page, int size, string sortBy = "Name", string sortDirection = "")
        {
            //Just make the sortDirection as optional Parameter
            throw new NotImplementedException();
        }
        // Another Solution
        internal void Print(List<Student> list, int page, int size, [Optional, DefaultParameterValue("Name")] string sortBy, string sortDirection)
        {
            // No Error, Its uses Reflection
            throw new NotImplementedException();
        }
    }

Color Your Web Page

 Right click on Page> Inspect Element> Console> Paste code> Press Enter

Your widow will be colored

----------------------------------------------------------------------------------------------------
[].forEach.call($$("*"),function(a){
  a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)
})
----------------------------------------------------------------------------------------------------

RDLC Report Footer Problem in DOC and PDF

Write following code
="Page " & Globals!PageNumber & " of " & Globals!TotalPages

instead of
="Page " + Globals!PageNumber.ToString() + " of " + Globals!TotalPages.ToString()


i. e. : replace + sign with &
  and remove ToString() casting

Language List for Dropdown List(HTML)

<select name="nationality">
  <option value="">-- select one --</option>
  <option value="afghan">Afghan</option>
  <option value="albanian">Albanian</option>
  <option value="algerian">Algerian</option>
  <option value="american">American</option>
  <option value="andorran">Andorran</option>
  <option value="angolan">Angolan</option>
  <option value="antiguans">Antiguans</option>
  <option value="argentinean">Argentinean</option>
  <option value="armenian">Armenian</option>
  <option value="australian">Australian</option>
  <option value="austrian">Austrian</option>
  <option value="azerbaijani">Azerbaijani</option>
  <option value="bahamian">Bahamian</option>
  <option value="bahraini">Bahraini</option>
  <option value="bangladeshi">Bangladeshi</option>
  <option value="barbadian">Barbadian</option>
  <option value="barbudans">Barbudans</option>
  <option value="batswana">Batswana</option>
  <option value="belarusian">Belarusian</option>
  <option value="belgian">Belgian</option>
  <option value="belizean">Belizean</option>
  <option value="beninese">Beninese</option>
  <option value="bhutanese">Bhutanese</option>
  <option value="bolivian">Bolivian</option>
  <option value="bosnian">Bosnian</option>
  <option value="brazilian">Brazilian</option>
  <option value="british">British</option>
  <option value="bruneian">Bruneian</option>
  <option value="bulgarian">Bulgarian</option>
  <option value="burkinabe">Burkinabe</option>
  <option value="burmese">Burmese</option>
  <option value="burundian">Burundian</option>
  <option value="cambodian">Cambodian</option>
  <option value="cameroonian">Cameroonian</option>
  <option value="canadian">Canadian</option>
  <option value="cape verdean">Cape Verdean</option>
  <option value="central african">Central African</option>
  <option value="chadian">Chadian</option>
  <option value="chilean">Chilean</option>
  <option value="chinese">Chinese</option>
  <option value="colombian">Colombian</option>
  <option value="comoran">Comoran</option>
  <option value="congolese">Congolese</option>
  <option value="costa rican">Costa Rican</option>
  <option value="croatian">Croatian</option>
  <option value="cuban">Cuban</option>
  <option value="cypriot">Cypriot</option>
  <option value="czech">Czech</option>
  <option value="danish">Danish</option>
  <option value="djibouti">Djibouti</option>
  <option value="dominican">Dominican</option>
  <option value="dutch">Dutch</option>
  <option value="east timorese">East Timorese</option>
  <option value="ecuadorean">Ecuadorean</option>
  <option value="egyptian">Egyptian</option>
  <option value="emirian">Emirian</option>
  <option value="equatorial guinean">Equatorial Guinean</option>
  <option value="eritrean">Eritrean</option>
  <option value="estonian">Estonian</option>
  <option value="ethiopian">Ethiopian</option>
  <option value="fijian">Fijian</option>
  <option value="filipino">Filipino</option>
  <option value="finnish">Finnish</option>
  <option value="french">French</option>
  <option value="gabonese">Gabonese</option>
  <option value="gambian">Gambian</option>
  <option value="georgian">Georgian</option>
  <option value="german">German</option>
  <option value="ghanaian">Ghanaian</option>
  <option value="greek">Greek</option>
  <option value="grenadian">Grenadian</option>
  <option value="guatemalan">Guatemalan</option>
  <option value="guinea-bissauan">Guinea-Bissauan</option>
  <option value="guinean">Guinean</option>
  <option value="guyanese">Guyanese</option>
  <option value="haitian">Haitian</option>
  <option value="herzegovinian">Herzegovinian</option>
  <option value="honduran">Honduran</option>
  <option value="hungarian">Hungarian</option>
  <option value="icelander">Icelander</option>
  <option value="indian">Indian</option>
  <option value="indonesian">Indonesian</option>
  <option value="iranian">Iranian</option>
  <option value="iraqi">Iraqi</option>
  <option value="irish">Irish</option>
  <option value="israeli">Israeli</option>
  <option value="italian">Italian</option>
  <option value="ivorian">Ivorian</option>
  <option value="jamaican">Jamaican</option>
  <option value="japanese">Japanese</option>
  <option value="jordanian">Jordanian</option>
  <option value="kazakhstani">Kazakhstani</option>
  <option value="kenyan">Kenyan</option>
  <option value="kittian and nevisian">Kittian and Nevisian</option>
  <option value="kuwaiti">Kuwaiti</option>
  <option value="kyrgyz">Kyrgyz</option>
  <option value="laotian">Laotian</option>
  <option value="latvian">Latvian</option>
  <option value="lebanese">Lebanese</option>
  <option value="liberian">Liberian</option>
  <option value="libyan">Libyan</option>
  <option value="liechtensteiner">Liechtensteiner</option>
  <option value="lithuanian">Lithuanian</option>
  <option value="luxembourger">Luxembourger</option>
  <option value="macedonian">Macedonian</option>
  <option value="malagasy">Malagasy</option>
  <option value="malawian">Malawian</option>
  <option value="malaysian">Malaysian</option>
  <option value="maldivan">Maldivan</option>
  <option value="malian">Malian</option>
  <option value="maltese">Maltese</option>
  <option value="marshallese">Marshallese</option>
  <option value="mauritanian">Mauritanian</option>
  <option value="mauritian">Mauritian</option>
  <option value="mexican">Mexican</option>
  <option value="micronesian">Micronesian</option>
  <option value="moldovan">Moldovan</option>
  <option value="monacan">Monacan</option>
  <option value="mongolian">Mongolian</option>
  <option value="moroccan">Moroccan</option>
  <option value="mosotho">Mosotho</option>
  <option value="motswana">Motswana</option>
  <option value="mozambican">Mozambican</option>
  <option value="namibian">Namibian</option>
  <option value="nauruan">Nauruan</option>
  <option value="nepalese">Nepalese</option>
  <option value="new zealander">New Zealander</option>
  <option value="ni-vanuatu">Ni-Vanuatu</option>
  <option value="nicaraguan">Nicaraguan</option>
  <option value="nigerien">Nigerien</option>
  <option value="north korean">North Korean</option>
  <option value="northern irish">Northern Irish</option>
  <option value="norwegian">Norwegian</option>
  <option value="omani">Omani</option>
  <option value="pakistani">Pakistani</option>
  <option value="palauan">Palauan</option>
  <option value="panamanian">Panamanian</option>
  <option value="papua new guinean">Papua New Guinean</option>
  <option value="paraguayan">Paraguayan</option>
  <option value="peruvian">Peruvian</option>
  <option value="polish">Polish</option>
  <option value="portuguese">Portuguese</option>
  <option value="qatari">Qatari</option>
  <option value="romanian">Romanian</option>
  <option value="russian">Russian</option>
  <option value="rwandan">Rwandan</option>
  <option value="saint lucian">Saint Lucian</option>
  <option value="salvadoran">Salvadoran</option>
  <option value="samoan">Samoan</option>
  <option value="san marinese">San Marinese</option>
  <option value="sao tomean">Sao Tomean</option>
  <option value="saudi">Saudi</option>
  <option value="scottish">Scottish</option>
  <option value="senegalese">Senegalese</option>
  <option value="serbian">Serbian</option>
  <option value="seychellois">Seychellois</option>
  <option value="sierra leonean">Sierra Leonean</option>
  <option value="singaporean">Singaporean</option>
  <option value="slovakian">Slovakian</option>
  <option value="slovenian">Slovenian</option>
  <option value="solomon islander">Solomon Islander</option>
  <option value="somali">Somali</option>
  <option value="south african">South African</option>
  <option value="south korean">South Korean</option>
  <option value="spanish">Spanish</option>
  <option value="sri lankan">Sri Lankan</option>
  <option value="sudanese">Sudanese</option>
  <option value="surinamer">Surinamer</option>
  <option value="swazi">Swazi</option>
  <option value="swedish">Swedish</option>
  <option value="swiss">Swiss</option>
  <option value="syrian">Syrian</option>
  <option value="taiwanese">Taiwanese</option>
  <option value="tajik">Tajik</option>
  <option value="tanzanian">Tanzanian</option>
  <option value="thai">Thai</option>
  <option value="togolese">Togolese</option>
  <option value="tongan">Tongan</option>
  <option value="trinidadian or tobagonian">Trinidadian or Tobagonian</option>
  <option value="tunisian">Tunisian</option>
  <option value="turkish">Turkish</option>
  <option value="tuvaluan">Tuvaluan</option>
  <option value="ugandan">Ugandan</option>
  <option value="ukrainian">Ukrainian</option>
  <option value="uruguayan">Uruguayan</option>
  <option value="uzbekistani">Uzbekistani</option>
  <option value="venezuelan">Venezuelan</option>
  <option value="vietnamese">Vietnamese</option>
  <option value="welsh">Welsh</option>
  <option value="yemenite">Yemenite</option>
  <option value="zambian">Zambian</option>
  <option value="zimbabwean">Zimbabwean</option>
</select>

Debug or Run SP in Oracle

Oracle SP
--------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE RPT_MFS_Revised_Journal (
   P_JOURNAL_DATE   IN     DATE := NULL,
   cur_OUT          IN OUT SYS_REFCURSOR)
AS
BEGIN
   OPEN cur_out FOR
        SELECT TO_CHAR (TransactionDate, 'DD/MM/YYYY') AS TransactionDate,
               TXCODE,              
          FROM T_Activity,            
         WHERE ( (T_Activity.IsRollBack = 0)
                OR (T_Activity.IsRollBack = 1                
      ORDER BY T_Activity.TxID;
END;
/
----------------------------------------------------------------------------------------------------------------------

Suppose
SP Name: RPT_MFS_Revised_Journal
Parameters:
P_JOURNAL_DATE   : '10/25/2014'


To Debug SP Write Following Code
---------------------------------------------------------------------
BEGIN
RPT_MFS_Revised_Journal (
   :P_JOURNAL_DATE,
   :cur_OUT);
END;
---------------------------------------------------------------------

Select code and click [Execute statement] from left side {blue play button}
A Variables window popup. Select date type for [P_JOURNAL_DATE] and input date('10/25/2014') and null for [cur_OUT]
Then click OK.

If Everything ok, then you got actual result.

Oracle Column type in SP Parameter

  p_FILEEXTENSION   IN    USACCTFLINFO.FILEEXTENSION%type := NULL


SP Parameter Name: p_FILEEXTENSION
Table Name: USACCTFLINFO
Table Column Name: FILEEXTENSION


If you want parameter type as column type then just write above code in SP

Text area Max Length by Jquery in asp.net

HTML
<asp:TextBox ID="txtmailingaddress1" runat="server" CssClass="textboxNormalLeftAligned inputField textarea200" TextMode="MultiLine" MaxLength="15" onkeyDown="checkTextAreaMaxLength2(this,event,'20');" />



From Last character will be deleted.

$('.textarea200').keyup(function () {
    var limit = 200; // parseInt($(this).attr('maxlength'));
    var text = $(this).val();
    var chars = text.length;
    if (chars > limit) {
        var new_text = text.substr(0, limit);
        $(this).val(new_text);
    }
});
-----------------------------------------------------------------------------------------

Character will not deleted but you can input Enter between word.

$("textarea.textarea2002").keydown(function (event) {
    var limit = 200;
    var text = $(this).val();
    var chars = text.length;
    alert(chars);
    if ((event.keyCode == null) || (event.keyCode == 0) || (event.keyCode == 8) || (event.keyCode == 9) || (event.keyCode == 13) || (event.keyCode == 27) || (event.keyCode == 33) || (event.keyCode == 34) || (event.keyCode == 35) || (event.keyCode == 36) || (event.keyCode == 37) || (event.keyCode == 38) || (event.keyCode == 39) || (event.keyCode == 40) || (event.keyCode == 46)) {} else {
        if (chars <= limit) {} else {
            event.preventDefault();
        }
    }
});

-----------------------------------------------------------------------------------------

You cant enter any value between string after 200 character length

function checkTextAreaMaxLength(textBox, e, mLen) {

    var mLen = textBox["MaxLength"];
    if (null == mLen)
        mLen = length;

    var maxLength = parseInt(mLen);
    if (!checkSpecialKeys(e)) {
        if (textBox.value.length > maxLength - 1) {
            if (window.event) //IE
                e.returnValue = false;
            else //Firefox
                e.preventDefault();
        }
    }
}

function checkSpecialKeys(e) {
    if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) {
        return false;
    } else {
        return true;
    }
}
-----------------------------------------------------------------------------------------
Run in JsFiddle:
http://jsfiddle.net/skpaik/L9brP

Run Stored Procedure in Oracle Toad Client

--- Procedure Name 'GetCashAccountByUserNumber'
--------------------------------------------------------------

CREATE OR REPLACE PROCEDURE GetCashAccountByUserNumber

(p_CREATEDBY     IN     NUMBER := NULL,
 p_CREATEDDATE   IN     DATE := NULL,
 p_UPDATEDBY     IN     NUMBER := NULL,
 p_UPDATEDDATE   IN     DATE := NULL,
 p_IPADDRESS            VARCHAR2 := NULL,
 p_FORMID        IN     NUMBER := NULL,
 p_UserNumber    IN     NUMBER DEFAULT NULL,
 p_BankKey       IN     NUMBER DEFAULT NULL,
 cur_OUT         IN OUT SYS_REFCURSOR)
AS
BEGIN
   OPEN cur_OUT FOR
        SELECT UserAccounts.UserKey,
               UserAccounts.AccountTypeKey,
               UserAccounts.UserNumber,
               SysAcct.SystemAccountID,
               SysAcctRefUsAcct.SystemAccountRefID,
               SysAcctRefUsAcct.UserCurrentBalance,
               SysAcctRefUsAcct.BlockedAmount,
               SysAcctRefUsAcct.IsVAT,
               SysAcctRefUsAcct.IsCOM,
               SysAcctRefUsAcct.IsActive,
               SysAcctRefUsAcct.ParentCode,
               SysAcct.AccountNumber,
               SysAcct.AccountDescription,
               UserAccounts.UserNumber ParentUserNumber
          FROM SysAcct
               JOIN SysAcctRefUsAcct
                  ON SysAcct.SystemAccountID = SysAcctRefUsAcct.SystemAccountID
               JOIN UserAccounts
                  ON SysAcctRefUsAcct.UserKey = UserAccounts.UserKey
               JOIN Bank
                  ON SysAcctRefUsAcct.BankKey = Bank.BankKey
                     AND UserAccounts.BankKey = Bank.BankKey
         WHERE     UserAccounts.UserNumber = p_UserNumber
               AND SysAcct.AccountNumber = '5008'
               AND UserAccounts.BankKey = p_BankKey
      ORDER BY UserAccounts.UserKey;
END;
/

--------------------------------------------------------------
To Run Open Editor
Write following code


BEGIN
E_GetCashAccountByUserNumber
(
 :p_CREATEDBY,
 :p_CREATEDDATE,
 :p_UPDATEDBY,
 :p_UPDATEDDATE,
 :p_IPADDRESS,
 :p_FORMID,
 :p_UserNumber,
 :p_BankKey,
 :cur_OUT
 );
 END;
--------------------------------------------------------------

Then Ctrl+A for select all code

Click on 'Excecute statement' Button

Give all Value type and Value


Press OK

SQL SERVER – Introduction to Rollup Clause

Create a Database
Then new Script
Then Fire this.
------------------------------------------------------------------------------

CREATE TABLE tblPopulation (
Country VARCHAR(100),
[State] VARCHAR(100),
City VARCHAR(100),
[Population (in Millions)] INT)
GO


INSERT INTO tblPopulation VALUES('India''Delhi','East Delhi',)
INSERT INTO tblPopulation VALUES('India''Delhi','South Delhi',)
INSERT INTO tblPopulation VALUES('India''Delhi','North Delhi',5.5)
INSERT INTO tblPopulation VALUES('India''Delhi','West Delhi',7.5)
INSERT INTO tblPopulation VALUES('India','Karnataka','Bangalore',9.5)
INSERT INTO tblPopulation VALUES('India''Karnataka','Belur',2.5)
INSERT INTO tblPopulation VALUES('India''Karnataka','Manipal',1.5)
INSERT INTO tblPopulation VALUES('India''Maharastra','Mumbai',30)
INSERT INTO tblPopulation VALUES('India''Maharastra','Pune',20)
INSERT INTO tblPopulation VALUES('India''Maharastra','Nagpur',11 )
INSERT INTO tblPopulation VALUES('India''Maharastra','Nashik',6.5)
GO



---To Display 


SELECT 
ISNULL(Country,'All Country') AS Country,
ISNULL([State],'All State') AS State,
ISNULL(City,'All City') AS City,SUM ([Population (in Millions)]AS [Population (in Millions)]FROM tblPopulationGROUP BY Country,[State],City WITH ROLLUP







Details: http://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause