GIT commands
|
initialize an existing directory |
|
retrieve an entire repository |
|
show modified files in working directory |
|
add a file as it looks now to your next commit |
|
unstage af ile while retaining the changs in working directory |
|
diff of what is changed but not staged |
git commit -m "[commit message]"
|
commit your staged content as a new commit snapshot |
|
list your branches, current has a * |
|
create a new branch at the current commit |
|
switch to another branch |
|
merge the specified branch into current one |
|
show all commits |
|
transmit local branch commits to remote repo |
|
fetch and merge any commits from the remote repo |
Regex
^ or \A |
Start of string |
$ or \Z |
end of string |
\b |
word boundary |
\B |
Not word boundary |
\s |
white space |
\S |
not white space |
?= |
look ahead |
?! |
negative lookahead |
* |
0 or more |
+ |
1 or more |
? |
0 or 1 |
{3} |
exactly 3 |
{3,} |
3 or more |
{3,5} |
3, 4, or 5 |
[a-z] |
lowercase a - z |
[A-Z] |
uppercase A-Z |
[^abc] |
not (a or b or c) |
[0-7] |
digits from 0 to 7 |
(a|C) |
a or C |
JavaScript String Objects
length |
property |
charAt(n) |
method |
charCodeAt(n) |
method |
l et a = "10"; let b = 20; console.log(a + b)
|
1020 |
let a = "10"; let b = 20; console.log(+a + b)
|
30 |
let a = "10"; let b = 20; console.log(a - b)
|
-10 |
let a = "10"; let b = 20; console.log(a * b)
|
200 |
l et a = “CST8285"; let b = 20; console.log(a - b)
|
NaN |
|
|
PHP - database connection
MYSQLi connection $dbc = mysqli_connect($host, $user, $pw, $db);
|
Query $result = mysqli_query($dbc, $query);
|
Close
|
JavaScript Math Objects
|
x to nearest integer |
|
x to the power of y |
|
square root of x |
|
absolute |x| |
|
random number between 0 (inclusive) to 1(exclusive) |
JavaScript Arrays
array.sort(function(a,b){return a-b})
|
array.sort((a,b) =>{a-b})
|
|
b sorted before value a |
|
a sorted before value b |
|
items stay inthe same spot |
array.filter(function(element) {return (comparison)}
|
array.filter((element) => {return (comparison)};
|
array.map((item)=>array.key);
|
new array containing only items with key |
|
add value to end of array |
|
remove value at end of array, returning value |
|
add value at start of array |
|
remove value at start of array, returning value |
array.splice(startingIndex, totalElementsToDelete, valuesToAdd)
|
add or remove elements anywhere in the array and returns deleted elements if any |
PHP functions
|
test if variable exists |
|
tests for empty variable |
mysqli_fetch_array($result)
|
fetch each row of query $result |
|
end script immediately |
|
remove leading and trailing whitespace |
|
read contents of $fn, returns array of strings |
file_get_contents($fn)
|
returns single string |
file_put_contents($fn, data, mode)
|
write content from data to $fn, using mode) |
|
checks if $fn exists |
|
returns array of lists of files and directories if $path is valid, else false |
|
returns array of all file names that match pattern, with path |
|
returns string of current working dir |
|
|
Cookies & Session
Cookies
- limited in size by browser
- stored client-side
- can be disabled
Sessions
- limited by server space
- stored server-side
- expire when browser closed
- cannot be modified by users |
PHP Session Commands
|
start a session |
$_SESSION["variableName"]
|
store session variable |
unset($_SESSION["variableName"]
|
remove session variable |
|
destroy session and all session variables |
JSON
easy to parse and generate |
can contain both object and array structures |
contain key and value pairs |
keys are always strings |
values can be string, number, Boolean, null, object, or array |
HAS no version, very stable, strictly in UNICODE |
Example object: $json = ' { "Name": "Alex", "Age": 37, "Admin": true } ' ; |
JSON in PHP
|
convert PHP array to JSON array |
|
changes above to reult in indexed array |
json_decode( $json, true))
|
JSON string to PHP array |
json_decode( $json, false) (default)
|
JSON string to PHP object |
|
take JS object and produce JSON string |
|
take JSON string and produce JS object |
PHP Error Reporting
error_reporting |
types of errors reported |
display_errors |
whether messages displayed in browser |
log_errors |
on server or somewhere else |
var | let | const
VAR |
LET |
CONST |
function-scoped |
block-scoped |
block-scoped |
updatable |
updatable |
not updatable |
redeclarable |
not redeclarable |
not redeclarable |
hoisted null |
not hoisted |
|