Sie sind auf Seite 1von 2

Compiling: turning written code into machine code, 1s and 0s

Make is not a compiler Breakpoint: explicitly define stopping point, allows you to inspect memory at that point and step through lines one at a time
Multithreading: performing multiple tasks at once Floating point imprecision
Heap:unallocated memory that can be dynamically used (MALLOC)
Stack: memory set aside when program starts
Scope: use pointers for values inside functions or your functions won't return same values Stack overflow: when stack runs out of space
remember to free dynamically allocated memory
.c files do not need a main function malloc allocates memory on the heap NULL does not demarcate the end of a string
Always check for NULL, also for malloc
Preprocessing: Directives like #include are processed, then inserts contents of header files and any declarations into file being preprocessed
Segmentation fault: attempts to access memory it isn't allowed to
Compiling: Preprocessed C code is translated into assembly, possibly with optimizations
Implicit declaration: program is defined after main function, no prototype OR no header file
Assembling: Assembly instructions translated into machine code and stored in object (.o) file Undeclared identifier: variable not declared
Remember to initialize pointers Remember $_POST
Linking: object code for main is combined with object code from other files, creating executable file
HTML is a markup language
Huffman coding: using frequency of ASCII characters, make BST
Recursion adds to the stack, consumes lots of memory and can cause segfaults and stack overflow, don't forget base case, leads to elegant code
HTTP: Port 80 Email: Port 25 HTTPS: Port 443
GIF is lossless JPEG is lossy
Programs may compile backdoors
PHPSESSID: cookie, value identifies user's browser, maps to server-side file containing $_SESSION which is superglobal PHP uses [ ]
mario
for(i=0,i<n,i++)
{ for(j=0,j<i,j++)
{ print(#);}
print(\n);}

typedef struct
{ type a;
type b;} structname;
(*ptr).str OR ptr->str

&variable = address (referencing)


*variable = actual value (dereferencing)
use pointers when actually manipulating vals
pointer arithmetic moves address x bytes

fgetcsv goes one line at a time


PHP: PHP Hypetext Processor
char: 1 byte
char*: 4 bytes
int: 4 bytes
int*: 4 bytes
long long: 8 bytes
long long*: 4 bytes
<type>*: 4 bytes
\n: newline
\r: return line to beginning of line
execute
bool nodesearch(node* list, int n)
{node* ptr = list;
while (ptr != NULL)
{if (ptr->n == n)
{return true;}
ptr = ptr->next;}
return false;}
void nodeinsert(int n)
{node* new = malloc(sizeof(node));
if (new == NULL)
{exit(1);}
new->n = n;
new->next = NULL;
new->next = head;
head = new;}

200 successfully respond to URL request


Browser looks up ip address
302 URL exists, but redirect client to other URL Contacts DNS server if needed
403 file access forbidden
Sends HTTP request to port vi nearby router
404 unable to find file
Upon receipt, website responds with HTML
500 server improperly configured or syntax error
301 URL permanently redirected, redirect client to another URL
401 Unauthorized

jQuery - for NULL return values


SQL Data Types: Note that p = precision, s = scale, n = fixed/max length. SMALLINT p = 5, INTEGER p = 10, BIGINT p = 19
$(document).ready(function() {})
CHARACTER(n)
BOOLEAN
SMALLINT DECIMAL(p,s)
DOUBLE PRECISION
#input element by id, and also tag name
VARCHAR(n)
VARBINARY(n)
INTEGER REAL
DATE
ex: $('#inputs').submit(function() {})
BINARY(n)
INTEGER(p)
BIGINT
FLOAT
TIME
only submits if return true
$('input').val();
SQL queries: UPDATE SELECT
FROM
WHERE
DELETE
INSERT INTO VALUES JOIN ON
js vs PHP: faster response, but invalid data if js disabled
C vs PHP: best for high-performance (compiled), but not as good for web programming and cmd line scripting
SQL vs CSV: more efficient, but requires server
trie vs hash: constant-time lookup (O(k) while hash = O(n)), but lots of memory
linked list vs array: dynamic size but bigger memory requirements
local vs global variable: restricts scope tightly, accessible when needed, global may simplify code
DOM: Document Object Model, each sublevel is node of upper level
More bytes than expected, some executable code overwrites return address return there,
Buffer-array attack, never make assumptions about user input length, users should use secure wifi and SSL sites
scanf must send value to address to alter the actual value if you don't initialize pointer value, you can write to wrong memory and get segfault
sscanf returns num of args filled
atomic transaction is either executed or not
associative array data structure that associates values with keys
external stylesheet centralizes styles, allows easy changes
MVC model-view-controller, design pattern separates business logic (C) from representation of data (M) from display of data (V)
for submitted php data: http://website.com/mvc.php?var1=val1&var2=val2&... etc
One-way hash: take variable-length string, output fixed-length, hard to do backwards
stacks are LIFO (last in, first out) structure, stack.size marks top of stack
insertion into hash table, separate chaining: Omega 1, O 1
insertion into trie: Omega 1, O 1
insertion into sorted linked list: Omega 1, O n
deletion from sorted linked list: Omega 1, O n
deletion from unsorted linked list: Omega 1, O n

queues are FIFO (first in, first out) structure, index of first element will change as dequeue

Ajax: asynchronous java and xml

ex: xhr.onreadystatechange = handler; calls handler on state change


ex: xhr.onreadystatechange = handler();, calls function immediately
Javascript: client-side programming language
Ajax: couples js with XML or JSON, can request additional data from servers via HTTP even after initial page load
jQuery: js library that simplifies common operations

If two websites on same server, share same IP address, Host header indicates desired domain
Anonymous function/lambda function: function without a name, passed as inputs to functions to be called later

gdb allows you to run program line by line


break
run
next
step
print
continue

Set a cookie store key-value pair in RAM or file for subsequent retrieval
If array var has f1 = v1, f2 = v2, etc. print(json_encode($var)) = {v1:f1, etc.)
HTML = structure
CSS = style SQL injection attack put in SQL code into field, cause SQL query to run unexpected code
for(var i in milo)
foreach($milo as $i)
for(var i in milo)
foreach($milo as $key => $value)
js arrays values can even be functions
console.log(i)
print($i)
console.log(milo[i])
print($key)
js, returns keys
php, returns values
js, returns values
php, returns key
Javascript, PHP are interpreted languages

<stdio.h>
int fclose(FILE* fp);
int fprintf(FILE* fp, string format);
size_t fread(void* ptr, size_t size, size_t blocks, FILE* fp);
FILE* fopen(string filename, string mode);
int fscanf(FILE* fp, string format);
int fseek(FILE* fp, long int offset, int from_where);
size_t fwrite(void* ptr, size_t size, size_t blocks, FILE* fp);
int scanf(string format);
int sprint(string ptr, string format);
int sscanf(const char *str, const char *format)

GET Ajax request example


$.get(url,function(price){
var msg = blah1+var1+blah2+var2+etc
$(#form_wrapper).html(msg);});

<string.h>
char* strcat(char* dest, const char* src);
char* strncat(char* dest, const char* src, size_t n);
int strcmp(string str1, string str2);
char* strtok(char* str, const char* delim);
<stdlib.h>
int rand(void); (pseudorandom btwn zero, RAND_MAX);
<ol></ol> - ordered list
<ul></ul> - unordered list
<li></li> - list element

htmlspecialchars($string) escapes users' input so it doesn't become HTML


mysql_real_escape_string($string) escapes users' inputs so it doesn't become SQL

<table></table> - table
<tr></tr> - table row
<td></td> - table data
void insert(int n) Insert: insert node into doubly linked list
{node* ptr = malloc(sizeof(node));
if (ptr != NULL)
{ptr->n = n;
ptr->prev = NULL;
ptr->next = list;
if (list != NULL)
{list->prev = ptr;}
list = ptr;}}
void remove(int n) Remove: remove node from doubly linked list
{node* ptr = list;
while (ptr != NULL)
{if (ptr->n == n)
{if (ptr == list)
{list = ptr->next;
if (list != NULL)
{list->prev = NULL;}}
else
{ptr->prev->next = ptr->next;
if (ptr->next != NULL)
{ptr->next->prev = ptr->prev;}}
free(ptr);
return;}
ptr = ptr->next;}}
int pop(void) Pop: take int at top of stack, else return -1

{if (stack.size == 0)
return -1;
return stack.numbers[--stack.size];}
bool push(int n) Push: take int and add to stack, else return false
{if (stack.size == CAPACITY || n < 0)
return false;
stack.numbers[stack.size++] = n;
return true;}
void traverse(node* root) Traverse: traverse binary search tree
{
if (root == NULL)
{
return;
}
traverse(root->left);
printf("%i\n", root->n);
traverse(root->right);
}
bool search(int n, node* tree) Search: searches binary search tree
{if (tree == NULL)
{return false;}
else if (n < tree->n)
{return search(n, tree->left);}
else if (n > tree->n)
{return search(n, tree->right);}
else
{return true;}}
find with recursion
bool find(node* root, int i)
{node* ptr = root;
while (ptr != NULL)
{if (i < ptr->i)
ptr = ptr->left;
else if (i > ptr->i)
ptr = ptr->right;
else
return true;}
return false;}

find without recursion


bool find(node* root, int i)
{if (root == NULL)
return false;
else if (i < root->i)
return find(root->left, i);
else if (i > root->i)
return find(root->right, i);
else
return true;}

bool odd(unsigned int n) Odd: checks for even or odd binary


{
if (n & 1)
return true;
else
return false;
}
<!DOCTYPE html>
<html><head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function() {
$("#inputs").submit(function() {
var value = $("#name").val();
if (value != "")
{alert("Hello, " + value + "!");}
return false;});});
</script>
<title>quiz</title>
</head><body>
<form id="inputs">
<input id="name" type="text"/>
<input id="button" type="submit" value="Greet"/>
</form></body></html>
check 2 vars with js
var val1 = document.getElementById("val1").value;
var val2 = document.getElementById("val2").value;
if (val1 == "" || val2 == "")
return false;
if (val1 != val2)
return false;
return true;
bool enqueue(int n) Enqueue: adds to end of queue
{if (q.size == CAPACITY || n < 0)
{return false;}
q.numbers[(q.size + q.front) % CAPACITY] = n;
q.size++;
return true;}
int dequeue(void) Dequeue: removes and returns int at front, forgets this val
{if (q.size == 0)
{return -1;}
q.size--;
int n = q.numbers[q.front];
q.front = (q.front + 1) % CAPACITY;
return n;}
PHP functions
require(filename.php)
echo
exit
empty

Das könnte Ihnen auch gefallen