MongoDB Cheatsheet

Starting: mongo Connect to database show dbs use local See database tables show collections db.funnytable.find() Regex db.funnytable.find( $or: [ {'name': { $regex: req.params.username, $options: 'i' }}, {'username': { $regex: req.params.username, $options: 'i' }}, {'email': { $regex: req.params.username, $options: 'i' }} ])

October 28, 2014  |  🏷️Mongo

MySQL Cheatsheet

Starting mysql # Same username, no password mysql -p # Password protected mysql -u user mysql -h hostname Create user CREATE USER me GRANT ALL PRIVILEGES ON database_name.* TO 'me'@'%'; ALTER USER 'me'@'%' IDENTIFIED BY 'newPass'; Connect to databaes SHOW DATABASES; SHOW DATABASES LIKE 'ok%'; USE mysql; See database tables SHOW TABLES; SHOW TABLES LIKE 'ok%'; SELECT * FROM important_stuffs; Extend tables ALTER TABLE important_stuffs ADD description VARCHAR(100); ALTER TABLE important_stuffs ADD description VARCHAR(100) AFTER severity; ALTER TABLE important_stuffs ADD description VARCHAR(100) FIRST; Delete from tables SELECT * FROM important_stuffs WHERE severity="low"; DELETE FROM important_stuffs WHERE severity="low"; Insert into tables INSERT INTO important_stuffs VALUES("Wow, so important", "high"); INSERT INTO important_stuffs SET description="Wow, so important", severity="high"; Show access rights SHOW GRANTS; Change all email addresses to my (when mailserver is activated) UPDATE users SET email= CONCAT('me+', id, '@iix....

Syscalls

64 bits 32 bits 16 bits 8 bits rax eax ax al rbx ebx bx bl rcx ecx cx cl rdx edx dx dl rsi esi si sil rdi edi di dil rbp ebp bp bpl rsp esp sp spl r8 r8d r8w r8b r9 r9d r9w r9b r10 r10d r10w r10b r11 r11d r11w r11b r12 r12d r12w r12b r13 r13d r13w r13b r14 r14d r14w r14b r15 r15d r15w r15b Links 64-bit syscalls 32-bit syscalls

August 29, 2014  | 

C Programming Cheatsheet

Links Full ncurses manual Apple Secure Coding C Gibberish (Decode C declarations) Some C #define tricks Cannot find stdio.h (or other headers) Install libc6-dev Case insensitive str(n)cpy #include <strings.h> int strcasecmp(const char *s1, const char *s2); int strncasecmp(const char *s1, const char *s2, size_t n); xmalloc void *xmalloc(size_t size) { void *ptr = malloc(size); if (ptr == NULL) { fprintf(stderr, "%s: Virtual memory exhausted\n", progname); abort(); } return ptr; } xrealloc void *xrealloc(void *ptr, size_t newsize) { ptr = realloc(ptr, newsize); if (ptr == NULL) { fprintf(stderr, "%s: Virtual memory exhausted\n", progname); abort(); } return ptr; } C Operator Precedence Operator - Description - Associativity () - Parentesis - Left-To-Right [] - Brackets ....

August 28, 2014  |