Show Menu
Cheatography

Review of some concepts

HTTP Status

Inform­ative
100
Continue
101
Switching Protocol
Success
200
OK
201
Created (POST)
202
Accepted
203
Non-Au­tho­rit­ative Inform­ation
204
No Content
Redirect
301
Move Perman­ently
Client Error
400
Bad Request
401
Unaith­orized
402
Payment Required
403
Forbidden
404
Not Found
408
Timeout
429
Too Many Requests
451
Illegal
Server Error
500
Internal Server Error
502
Bad Gateway
503
Service Unavai­lable

Python

List
lst
[10, 20, 30, 40, 50]
lst[:-1]
[10, 20, 30, 40]
lst[1:-1]
[20, 30, 40]
lst[::2]
[10, 30, 50]
lst[::-1]
[50, 40, 30, 20, 10]
 
and, or, not, True False
 
Import
from mod import mod1, mod2
mod1()
import mod
mod.mod1()
 
Operators
+ - / // % *
a
Operations
.len()
.sorte­d(list)
list.s­ort()
.rever­sed­(list)
list.r­eve­rse()
 
Lists Operations
.append()
[ , , []]
.extend()
[ , , , ]
.inser­t(i­ndex, value)
.remove()
 
Dictio­naries Operations
{key: value}
d[key]
value
.update()
.values()
.keys()
a
Strings
.count()
.index()
.upper()
.capit­alize()
.split­("_")
.strip­(" ")
Remove todos os caracteres
 

MySQL

SELECT column1, column2 FROM table_name WHERE x = "­ads­" ORDER BY column1 DESC
SELECT COUNT(­col­umn­_name) FROM table_name WHERE condition;
SELECT AVG(co­lum­n_name) FROM table_name WHERE condition;
SELECT SUM(co­lum­n_name) FROM table_name WHERE condition;
SELECT column1, ... FROM table_name WHERE columnN LIKE pattern;
% - any, _something
 
INSERT INTO table name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...)
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition
DELETE FROM table_name WHERE condition
CREATE TABLE table_name (column1 datatype, column2 datatype, ...)
 
DROP TABLE table_name
DROP DATABASE databa­sename
ALTER TABLE table_name ADD column­_name datatype;
ALTER TABLE table_name DROP COLUMN column­_name;
ALTER TABLE table_name MODIFY COLUMN column­_name datatype;

Java

Arrays
.equal­s(O­bject[] arr1, Object[] arr2)
.sort(­Obj­ect[] arr)
.toStr­ing()
 
String
.index­Of(char a)
.charA­t(int index)
.equal­s(S­tring s)
.forma­t(S­tring s, int 1, String 2, int 3, ...)
.length()
.subSt­rin­g(int beginI­ndex, int endIndex)
.toLow­erC­ase()
.toUpp­erC­ase()
 
List<E>
.add(int index, E element)
.add (E element)
.conta­ins­(Object o)
.get(int index)
.index­Of(­Object o)
.isEmpty()
.remov­e(int index)
.remov­e(O­bject o)
.set(int index, E Element)
.size()
.toArray()
.subLi­st(int fromIndex, int toIndex)
 
HashMa­p<O­bject Key, Object Value>
.get(O­bject Key)
.put(Key key, Value value)
.remov­e(O­bject key)
.replace(K key, V value)
.size()
.values()
.conta­ins­Key­(Object Key)
.conta­ins­Val­ue(­Object Value)
 
HashSe­t<E>
.add(E e)
.conta­ins­(Object o)
.remov­e(O­bject o)
.size()
.isEmpty()
.clear()
 
jUnits
void teste(){ ... }
assert­Equ­als­(exp, comp)
 

GIT

Criar repo
git init
Aceder a staging area
git status
Adicionar ficheiro a Staging Area
git add {nome do ficheiro}
Remover da Staging Area
git reset HEAD -- <fi­le>
Dar commit
git commit -m "­Commit messag­e"
Criar novo branch
git branch <ne­w-b­ran­ch-­nam­e>
Mudar de branch
git checkout {branch}
Merge Branch
git merge <br­anc­h-n­ame>
Push para remoto
git push <re­mot­e> <br­anc­h>
Atualizar
git pull
Remover ficheiro do reposi­torio
git rm <fi­le>

Mongoose

Schema.cr­eate({ nome: name, password })
Schema.fi­ndOne({ _id: id })
Schema.find({ name: name })
Schema.ex­ists({ _id: id })
Schema.up­dat­eMany({ {_id: id}, {name: name} })
Schema.de­let­eOne({ _id: id })

SOLID Principles

Single Respon­sib­ility
Class can have one respon­sib­ility
Open/C­losed
Interfaces = - if's
Liskov Substi­tution
Subclass can do what Super does
Interface Segreg­ation
Threed­ime­nsional shape x shape
Dependency Inversion

ExpressJS

const express = requir­e('­exp­res­s')();
Get
app.ge­t('­/info', (req, res)=>{})
Post
app.po­st(­'/:id', (req, res) => {))
 
Send
res.st­atu­s(2­00).se­nd({})
Redirect
res.re­dir­ect­(301, '/')

ReactJs

render­(){­ret­urn­(<d­iv>...<­/d­iv>)}
Array => .map(() => { ... })
onClick = {() => this.h­and­leS­ome­thi­ng()}
Counters: <Co­unter onDele­te=­{}/>
Counter: this.p­rop­s.o­nDelete
 
Class
state = {...js­on...}
this.s­etS­tat­e({­count: this.s­tat­e.count + 1})
 
compon­ent­Did­Mount
compon­ent­Did­Update
compon­ent­Wil­lUn­mount
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          My Ubuntu Cheat Sheet Cheat Sheet
          JAVA keytool Cheat Sheet