- install json server on windows
npm install -g json-server - run json server
json-server -p 5555 products.json - https://www.youtube.com/watch?v=HCHvrbAd1QA
- https://www.youtube.com/watch?v=WVlNj_6_-uA
- https://www.youtube.com/watch?v=6T1TF7lgVSA
- Angular 4 POST
- Angular 4 Receive data in Php
Author: admin
Angular 4 Deployment
Use any of the commands:
- ng build
- ng build –prod
- ng build –prod –base-href /directory-name/sub-directory-name/
Create testing branch on github
- add normal git repository
- git branch gh-pages
- git push -u origin gh-pages
To push on the git repository
- git init
- git add origin
- git add .
- git commit -m “Initial Commit”
- git push -u origin master
- ng build –prod –base-href https://whateveruser.github.io/whateverprojectrepo/
- ngh
ng build –prod –base-href https://github.com/whateveruser/whateverprojectrepo/
Ref:
- https://www.youtube.com/watch?v=nxV3weqMzYo
.htaccess for production site
RewriteEngine on # Don't rewrite files or directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # Rewrite everything else to index.html to allow html5 state links RewriteRule ^ index.html [L]
OOPS
- Design a class Rectangle
data members[box title=”” bg_color=”#dbdbdb” align=”left”]length
breadth[/box]member functions/methods[box title=”” bg_color=”#dbdbdb” align=”left”]setDimension()
area()
perimeter()[/box] - Design a class Worker
data members[box title=”” bg_color=”#dbdbdb” align=”left”]wages
wdays[/box]member function / method[box title=”” bg_color=”#dbdbdb” align=”left”]setData()
payment()[/box] - Design a class Box
data members[box title=”” bg_color=”#dbdbdb” align=”left”]length
breadth
height[/box]member functions / methods[box title=”” bg_color=”#dbdbdb” align=”left”]setDimension()
volume()[/box] - Design a class Rectangle (only for Java / C++)
data members[box title=”” bg_color=”#dbdbdb” align=”left”]length
breadth[/box] member functions / methods[box title=”” bg_color=”#dbdbdb” align=”left”]setDimension()
area()
perimeter()[/box]It must overload setDimension() method twice:- by passing 1 argument
- by passing 2 arguments
- Design a class Box (only for Java / C++)
data members[box title=”” bg_color=”#dbdbdb” align=”left”]length
breadth
height[/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”]volume()[/box] It must contain 3 constructors- 1 parameter
- 2 parameter
- 3 paramter
- Design a class Account
data members [box title=”” bg_color=”#dbdbdb” align=”left”]balance[/box]member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] deposit(amt)
withdraw(amt)
showBalance()[/box] - Design a class Set
data members [box title=”” bg_color=”#dbdbdb” align=”left”]3 numbers[/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] SUM()
MEAN()
MAX()
MIN() [/box] - Design a class Student
data members [box title=”” bg_color=”#dbdbdb” align=”left”]roll_number
name [/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] setData()
getData() [/box] - Design a class Account
data members [box title=”” bg_color=”#dbdbdb” align=”left”] balance
interest_rate [/box] interest_rate must be shared by all objects (static modifier) and its default value 10.25 [box title=”” bg_color=”#dbdbdb” align=”left”] interest(no_of_years) [/box] - Design a class Student
data members [box title=”” bg_color=”#dbdbdb” align=”left”] roll_number
name [/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] setData()
getData() [/box] - Design a class Account
[box title=”” bg_color=”#dbdbdb” align=”left”] account_number
balance
interest_rate [/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] interest(no_of_years) [/box] - Design a class Student
data members [box title=”” bg_color=”#dbdbdb” align=”left”] roll_number
name [/box] member function / methods [box title=”” bg_color=”#dbdbdb” align=”left”] getData() [/box] roll_number must be automatically generated.It also keep track of total number of Students. - Design a package MyCircle and MyRectangle (Only for Java)
[box title=”” bg_color=”#dbdbdb” align=”left”] radius
length
breadth [/box] member functions / methods: [box title=”” bg_color=”#dbdbdb” align=”left”] area()
circumference()
perimeter() [/box] - Design a class Student
data members [box title=”” bg_color=”#dbdbdb” align=”left”] roll_number
name [/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] getData()
showData() [/box] Create 5 objects of Student using Array - Design a class Student and List ClassRoom
add list of Students in ClassRoom
display List - Design a class Account and List Bank
add list of Account in Bank
display List - Create array of Student Objects
data members [box title=”” bg_color=”#dbdbdb” align=”left”] roll_no
name
college [/box] member functions / methods [box title=”” bg_color=”#dbdbdb” align=”left”] readData()
showData() [/box] - Create a class RBI (Only for Java)
data members [box title=”” bg_color=”#dbdbdb” align=”left”] balance [/box] member functions [box title=”” bg_color=”#dbdbdb” align=”left”] RBI()
deposit(int amt)
withdraw(int amt)
showBalance() [/box]
Freemarker Template
Array to CSV in Java
package com.demo; import java.io.IOException; import com.csvreader.CsvWriter; public class ArrayToCSVDemo { public static void main(String[] args) { String array[] = {"Suryanagar, Vikhroli", "Java", "SQL", "13"}; try { CsvWriter writer = new CsvWriter("awesomefile.csv"); writer.writeRecord(array); writer.close(); } catch (IOException e) { e.printStackTrace(); } } }
Reference Link: http://www.journaldev.com/12014/opencsv-csvreader-csvwriter-example
Jar File: http://www.java2s.com/Code/Jar/j/Downloadjavacsvjar.htm
Using FileWriter class
import java.io.FileWriter; public class TestFileWriter { public static String implodeString(String[] split) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < split.length; i++) { sb.append(split[i]); if (i != split.length - 1) { sb.append("\",\""); } } return "\"" . concat(sb.toString()) .concat("\""); } public static void main(String[] args) { String array[] = {"Suryanagar, Vikhroli", "Java", "SQL", "13"}; try { FileWriter fw = new FileWriter("testout.csv"); //fw.write("\"Suryanagar, Vikhroli\", Java, SQL, 13"); fw.write(implodeString(array)); fw.close(); } catch (Exception e) { System.out.println(e); } System.out.println("Success..."); } }
Hello World django
Here are simple steps to create hello world web application in python using django framework
- Step 1: Install virtual environment and create virtual environment for your project
pip install virtualenvwrapper-win
mkvirtualenv myproject
-
pip install virtualenv
-
virtualenv name_to_your_env
-
name_to_your_env\Scripts\activate
-
After activation $ django-admin.py startproject HelloWorld
$ cd HelloWorld
$ ls HelloWorld manage.py
-
$ python manage.py runserver Validating models... 0 errors found ... Django version 1.6.5, using settings 'HelloWorld.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
- $ django-admin startapp HelloWorldApp
$ ls
HelloWorld HelloWorldApp manage.py - edit settings.py under HelloWorld project directory
# Application definition
INSTALLED_APPS = ( ‘django.contrib.admin’,
‘django.contrib.auth’,
‘django.contrib.contenttypes’,
‘django.contrib.sessions’,
‘django.contrib.messages’,
‘django.contrib.staticfiles’,
‘HelloWorldApp’, ) - modify the urls.py which is under the project directory, HelloWorld
from django.conf.urls import patterns, include, url from HelloWorldApp.views import foo #from django.contrib import admin #admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'HelloWorld.views.home', name='home'), # url(r'^blog/', include('blog.urls')), #url(r'^admin/', include(admin.site.urls)), url(r'HelloWorldApp/$', foo), )
- modify views.py under app directory, HelloWorldApp
# Create your views here. from django.http import HttpResponse def foo(request): return HttpResponse("Hello World!")
- Run the server
python manage.py runserver
- Hit this URL on browser
http://localhost:8000/HelloWorldApp/
Ref Links:
- https://docs.djangoproject.com/en/1.11/howto/windows/
- http://www.bogotobogo.com/python/Django/Python_Django_hello_world.php
- https://stackoverflow.com/questions/18684231/python-setup-command-not-found
- https://stackoverflow.com/questions/8074955/cannot-import-name-patterns
- https://scotch.io/tutorials/build-your-first-python-and-django-application
- http://jinja.pocoo.org/docs/2.10/templates/
Installation
git clone https://github.com/angular/quickstart.git quickstart
Apache POI (Poor Obfuscation Implementation File System)
Prerequisite
Download all poi jar files
https://poi.apache.org/download.html
- Terms
- Workbook – The file contains number of sheets
- Sheet – Matrix contains rows and cell
- Row – Record of an entity in one row
- Cell – A single cell which hold value
-
JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showDialog(null, "Select File"); if(returnValue == JFileChooser.APPROVE_OPTION) { Workbook workbook = new HSSFWorkbook(new FileInputStream(fileChooser.getSelectedFile())); Sheet sheet = workbook.getSheetAt(0); for(Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();){ for(Iterator<Cell> cit = rit.next().cellIterator(); cit.hasNext();){ System.out.println(cit.next()); } System.out.println(""); } } else { System.out.println("Invalid output"); }
-
JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showDialog(null, "Select File"); if(returnValue == JFileChooser.APPROVE_OPTION) { FileInputStream excelFile = new FileInputStream(fileChooser.getSelectedFile()); Workbook workbook = new XSSFWorkbook(excelFile); Sheet sheet = workbook.getSheetAt(0); for(Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) { for(Iterator<Cell> cit = rit.next().cellIterator(); cit.hasNext();) { System.out.print(cit.next() + "\t" + cit.next()); } System.out.println(""); } }
-
Workbook workbook = new HSSFWorkbook(); Sheet sheet1 = workbook.createSheet("movies"); // Sheet sheet2 = workbook.createSheet("Test Cases"); // Sheet sheet3 = workbook.createSheet(WorkbookUtil.createSafeSheetName("$*(^&?")); Row row = sheet1.createRow(0); // Cell cell = row.createCell(4); // cell.setCellValue("Hello World"); // Cell cell2 = row.createCell(3); // cell2.setCellValue("terminator"); // System.out.println(cell.getRichStringCellValue().toString()); // System.out.println(cell2.getRichStringCellValue().toString()); Cell cell1 = row.createCell(0); Cell cell2 = row.createCell(1); Cell cell3 = row.createCell(2); Cell cell4 = row.createCell(3); Cell cell5 = row.createCell(4); cell1.setCellValue(5); cell2.setCellValue("+"); cell3.setCellValue(6); cell4.setCellValue("="); cell5.setCellFormula("A1+C1"); try { FileOutputStream outputStream = new FileOutputStream("test1.xlsx"); workbook.write(outputStream); outputStream.close(); } catch (Exception e) { e.printStackTrace(); }
- Complete Program
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import javax.swing.JFileChooser; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.WorkbookUtil; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * * @author Shailesh Sonare */ public class ApachePOIDemo { /** * @param args the command line arguments */ public static void main(String[] shailesh) throws IOException { /* Workbook workbook = new HSSFWorkbook(); Sheet sheet1 = workbook.createSheet("movies"); // Sheet sheet2 = workbook.createSheet("Test Cases"); // Sheet sheet3 = workbook.createSheet(WorkbookUtil.createSafeSheetName("$*(^&?")); Row row = sheet1.createRow(0); // Cell cell = row.createCell(4); // cell.setCellValue("Hello World"); // Cell cell2 = row.createCell(3); // cell2.setCellValue("terminator"); // System.out.println(cell.getRichStringCellValue().toString()); // System.out.println(cell2.getRichStringCellValue().toString()); Cell cell1 = row.createCell(0); Cell cell2 = row.createCell(1); Cell cell3 = row.createCell(2); Cell cell4 = row.createCell(3); Cell cell5 = row.createCell(4); cell1.setCellValue(5); cell2.setCellValue("+"); cell3.setCellValue(6); cell4.setCellValue("="); cell5.setCellFormula("A1+C1"); try { FileOutputStream outputStream = new FileOutputStream("test1.xlsx"); workbook.write(outputStream); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } */ /* JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showDialog(null, "Select File"); if(returnValue == JFileChooser.APPROVE_OPTION) { Workbook workbook = new HSSFWorkbook(new FileInputStream(fileChooser.getSelectedFile())); Sheet sheet = workbook.getSheetAt(0); for(Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();){ for(Iterator<Cell> cit = rit.next().cellIterator(); cit.hasNext();){ System.out.println(cit.next()); } System.out.println(""); } } else { System.out.println("Invalid output"); } */ JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showDialog(null, "Select File"); if(returnValue == JFileChooser.APPROVE_OPTION) { FileInputStream excelFile = new FileInputStream(fileChooser.getSelectedFile()); Workbook workbook = new XSSFWorkbook(excelFile); Sheet sheet = workbook.getSheetAt(0); for(Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) { for(Iterator<Cell> cit = rit.next().cellIterator(); cit.hasNext();) { System.out.print(cit.next() + "\t" + cit.next()); } System.out.println(""); } } } }
polymorphism
class A { public void test(){ System.out.println("hello"); } public void foo(){ System.out.println("fooo"); } } class B extends A { @Override public void test(){ System.out.println("world"); } public void bar(){ System.out.println("baar"); } } public class PolymorphismDemo { public static void main(String[] args) { A a = new A(); a.test(); // allowed: will print hello a.foo(); // allowed: will print fooo //a.bar(); // not allowed: compile time error B b = new B(); b.test(); // allowed: will print world b.foo(); // allowed: will print fooo b.bar(); // allowed: will print baar A c = new B(); c.test(); // allowed: will print world c.foo(); // allowed: will print fooo //c.bar(); // not allowed: compile time error //B d = new A(); // not allowed: compile time error A e = new B(); A f = (A)e; f.test(); // allowed: will print world f.foo(); // allowed: will print fooo //f.bar(); // not allowed: compile time error B g = new B(); A h = (A)g; h.test(); // allowed: will print world h.foo(); // allowed: will print fooo //h.bar(); // not allowed: compile time error } }
programs on pointers
- WAP to exchange values of 2 variables by calling a function exchange
- WAP to find length of a string by calling a function lenght
- WAP to copy contents of one string into another by calling a function copy.
- WAP to reverse contents of a string
- WAP to find sum of 10 int values by calling a function sum (passing array as an argument)
- WAP to find mean of 10 in values by calling a function MEAN (passing array as an argument)
- WAP to dynamically read n values and find their sum
- WAP to read information about n students and display them
- WAP to find area and circumference of a circle by calling a single function circle
- WAP to call functions area and circumference of circle by using function pointer
- WAP to count total number of words in a string by calling a function wcount
- WAP to read a String and coutn total vowels in that string
- WAP to read a string and count total no of digits in that string
- WAP to read a string and copy it into another array
- WAP to rad a string and reverse that string