Please enable JavaScript.
Coggle requires JavaScript to display documents.
IT Sumary (C (format ('#include (<stdlib.h>, <ctype.h>,…
IT Sumary
C
define: low level languages
format
functions implements
return type function_name(parameters) {}
int main (int agrc, char *agrv[]) {}
'#define name value/type
global variables declare
type variable_name;
functions declare
return type function_name (parameters);
'#include
<stdlib.h>
<ctype.h>
<string.h>
<stdio.h>
<stdint.h>
typedef type name;
basic type
int, float, long, char, void,
struct
struct name {} name;
pointer
value of pointer is address of other memory
declare
basictype *name_pointer
*pointer = value of the memory which is pointed by pointer
&variable equal value of address of variable
parameter
pass by value
pass by reference
it can change the value of parameter
pass address of variables
array
format: type name[X];
name is a pointer point to the very firrst mem of array
array is set of side by side memory squares
string
define: is array of char, end by '\0'
functions: strlen(char*) = length of string
when use malloc to create string, note that + 1 for the end character
heap memory
define: memory use for memory dynamic allocate
syntax
pointer_variable = malloc(size (byte));
FIFO
stack memory
memory use for functions
LIFO
loop
for (int i = 0; i < 10; i++) {}
while (true) {}
do {} while (true);
conditions
if (boolean) {} else if (boolean) {} else {}
a = bolean ? x : y;
switch (variable) {case value: statements; break;}
io
standard i/o
printf("abc %i", x);
scanf(stdio, &x);
getc
putc
file
FILE *pointer = fopen(path, "r or rb or w or wb");
fread()
fwrite()
Web security
SQL injection
Use user input to concat direct to sql query.
Solution: pass user input as parameter to sql query
XSS
Cross site script: inject script to webserver, often to get information of user in cookie
Solution: Use encode HTML or encode XML input from user or when dislay data from DB to user
XSRF
cross site request forgery: fake request to websever from other domain.
Solution with struts 1: use saveToken(req) on the page before important aciton take place. Attach this token to the jsp. After user send the action, check the token on server by isValidToken(req,true) .
HTTP cooki only
avoid javasript to read the cookie
File inclusion
use white list extention file allowed upload to server
Expose system data
file on server should not store on the same folder of webserver. And don't allocate the run permission on the store file upload folder
User enumeration
user and password share the same notify to user when wrong
URL redirection without checking
use white list URL redirect from our domain
Xml injection
hacker inject xml tags to xml file on server
solution: use xml encode
Command injection
don't use user input as a system command. If must do so, use white list command
Java Core
Basic data types
int, char, byte, short, long, float, double, Date, List, array, ArrayList, Enum
Data structure
LinkedList, HashTable, Map, HashMap, SortedMap, Stack, Queue (interface -> concrete class: LinkedList
Object oriented
Inheritance
subclass inherit states and methods of the superclass
encapsulation
hidden the internal states and allowed interaction with the states only through exposed methods
interface
is a contract between a class and outside world. If a class implements an interface, it must implements all abstract methods of that interface
package
a namespace that organizes classes, interfaces which have common attributes
objects
reflect real world object. fields reflects states. methods reflect behaviors
class
objects share common states and behaviors are put into a class. class define common fields and methods of objects
abstraction
is like interface, but it have its own state and method (not abstract method like interface).
overriding
methods of subclass can override methods of superclass
polymorphism
is the ability of an object can take on many forms. Example: super class reference can be super object or sub object. interface reference can be many type of objects of class that implement that interface
Generic type
Multi thread
define: is dividing an application to a number of parts, in which each parts do their task concurrently. Each task is runned in a thread. All thread share the same memory of the application.
implements
extends Thread class and overriding the run() method
Implements Runnable interface and implement the run() methods
create the inner class implement Runnable or extends Thread class
synchonized
join
the main thread will wait until the thread of join is finished
viaolient
some cpu copy variable to internal memory. Declare vialolient to avoid asynchorize
notify and wati
wait will cause the thread wait until other thread call notify
multi process vs multi thread
Socket program
define: interaction between devices through network.
Socket program
ServerSocket (host, port)
Socket s = server.accept();
Must while (true) when accept from client Socket
URL processing
variables
reference variables
local variables
instance variables
static variables
HTTP
define: hyper text transfer protocol. It base on TCP/IP protocol. It is used for transfer media message between devices over TCP/IP network
Characteristics
stateless
non case sensitive in URL
default port : 80
URL: Uniform request language. format:
http://host:port/resource
path
format HTTP message:
HTTP headers \n line break \n body messages
HTTP request headers
HTTP verbs
GET
POST
PUT
DELETE
HEAD
CONNECT
OPTION
TRACK
tags
content-length:90
content-type:text/plain
MIME: media type
....
HTTP response headers
status
1xx: information
2xx: success
3xx: Redirection
4xx: request errors
5xx: server errors
model
client: Browser
server: web server (apache , IIS)
server side script: java, python
Java web framework
Struts 1
Struts 2
Spring MVC
Hibernate
data structure
define: structure in memory to store data
Basic data type
int, char, float, double, void
date, file, pointer
array
Abstract data type
linked list
define: it's an dynamic array, don't need to identify the size of the array in advance. Use malloc to create new node and add it to the linked list.
Implements: use structure like: node {int value; node *next}. Last node point to NULL
hash table
define: it the array of linked list
Implements: each element must have an hash code to find which stack it belong to. To generate hash code, we use hash function. Hash function for number: x mod n to hash table to n stacks
binary tree
define: it's an abstract data type. It is like a tree. It have 1 root. Each node has maximum 2 child. The leaf node doesn't have child. Structure of each node: {int value; node
left; node
right. Left node value < parent node value < right node value.
dictionary search tree
define: It an array of tree with many root. Each node value is a character. Go to from each root to a leaf, we have a word.
queue
define: it's an array that provide rule: first in first out
Implements: Use linked list. When put: insert to the last position of the list
stack
define: it's an array that provide rule: first in last out
Implements: Use linked list , put new elements: insert to the first position of the list
algorithm
define
take some input, execute sets of instructions to solve some problems and create the output (to solve problems)
input: just only binary: 1 and 0; represented by electric (or wave) and switch.
input may present: numbers, characters, images, files, voices, video...
sort
insertion sort
define: 1. browse from 0 to n - 1; 2. insert each elements to left hand side of array and ensure that the left hand side is always sorted.
running time: O (n2)
bubble sort
define: 1. browse from 0 to n - 1; 2. if elements [i] and elements[i+1] is not sorted, swap them; 3. loop this until no swap happen.
running time: O (n2)
selection sort
define: 1. browser each element of array. 2. in the i-th browse find the smallest of remain arrays , and swap it with array[i].
running time: O(n2)
merge sort
define: 1. divide the array to two sub arrays.2. sort left arrays. 3. sort right array. 4. merge two sorted array
running time: O (n* logn)
count sort
define: use for sort array with max value of each elements is not big (<= 10000). Create an array having size = max elements values. Browse each value in array, assign new_array[value] = 1. Browse from 0 to n-1 in new_array, check if new_array[i] = 1 then assign to old_array[j]
running time: O(n)
search
linear search
define: browse each elements in array to find search item.
running time: O(n)
binary search
define: search in sorted array. compare search item with middle item of the array. If not found , continue search the left or right side of the array (depend on the search item is larger or smaller the middle item)
Running time: O(log (n))
Web technology
Javascript
document.getElementById("id"). (value, style.color, innerHTML)
library
angularJS
define: is a framework of javascript, support binding model, navigating, be controller for web client.
format
ng-app="module name" : define a module of angularJS
ng-controller="controller name" define controller of a module
ng-model="model name": mapping form elements with object of angularJS. They are synchronized together
$scope: is the scope of controller
$rootscope: is the global scope that all controller in an application can access its objects and methods
directive: is some funcitons that is encapsulated of angularJS. It may be attributes, class, new elements
some common directives
ng-click, ng-show, ng-if
ng-repeat="x in arrays_name": repeat the elements containing ng-repeat
filters
filter values through it
some filters
data-translator
currency, date, json, number, lowercase, orderBy, uppercase
{{variables | filters}}
service
define: is some class containning function & attributes, it's called by controllers
some common services
$location (related to uri of apps)
$http: use to call ajax http methods (get, post..)
$http.get("uri").then(function success (response){content of functions}, function error(response) {});
expressions
{{variables or functions}}
ng-bind
js commands
declare app
var app = angular.module("module name", [$scopes and service declare]);
declare controllers
app.controller("controller name", function ($scope, service) {commands of controller});
declare directives
app.directive("directive name", function () {content of directive});
declare service
jquery
Read Google doogle
CSS
declare
use style attribute in html tag: style="color: #fff;"
use class attribute: .className {color: #fff;}
Through id of html tag: #IdName{color: #fff'}
use in css selector manner: follow by document hierachy. div #div1 #div2 .id1 {}
basic attributes
border: solid 1px #ddd; border-radius: 5px: make circle dgree corner of block
margin: white space around element
padding: white space between border and content of element
background-color
color
font-size; font-weight; font-size
width, height
position: relative, fixed, absolute
top, right, bottom, left: fix position relative to the monitor
unit
px
em
%
HTML
format
<DOCTYPE! html>
<html></html>
<head></head>
<title></title>
<style></style>
<meta></meta>
<body></body>
<h1><h2><h3><h4><h5><h6>
<p><span>
<b><i><del><insert>
<div><table><th><td><tr><td><fieldset>
<hr>
<pre>
<img><a>
<input>
<input><select><option>
attributes
id, name
style
color
font-family
Tahoma
Time new romans
Arial
format: css tag: css value;
background-color
width, height
float: left, right, center: to create menu
padding: space from content to border
margin: from border to other blocks
src
href
alt
value
disable
width , height (for <img>)
onclick
block
<table>
style
border-collapse: collapse
border: solid 1px #dddddd
<div>
layout
<header>
<nav>
<ul><li> : to create menu
float: left
overflow: hidden to hozirontal menu
<section>
<article>
<aside>
<footer>
define: hyper text markup languages. It is use to display content on web pages. It uses tags to display content.
Common questions
Database tunning
Webservices