mirror of
https://github.com/LeCoupa/awesome-cheatsheets.git
synced 2026-01-29 14:48:01 -08:00
Compare commits
10 Commits
8363525666
...
8ad13861f3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ad13861f3 | ||
|
|
559d03ecf3 | ||
|
|
bea751612a | ||
|
|
d143c60246 | ||
|
|
44371217a9 | ||
|
|
d63d75bb28 | ||
|
|
94087440e5 | ||
|
|
2f1e798f54 | ||
|
|
d0f3d05919 | ||
|
|
bef420a611 |
@@ -95,6 +95,14 @@ Feel free to take a look. You might learn new things. They have been designed to
|
|||||||
- [Redis](databases/redis.sh)
|
- [Redis](databases/redis.sh)
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
#### Cheat Class
|
||||||
|
<details>
|
||||||
|
<summary>view cheatsheets</summary>
|
||||||
|
|
||||||
|
- [PDO](cheatclass/PDO.php)
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
### 🔧 Tools
|
### 🔧 Tools
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
|||||||
88
cheatclass/PDO.php
Normal file
88
cheatclass/PDO.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* PDO DATABASE CLASS
|
||||||
|
* Connects Database Using PDO
|
||||||
|
* Creates Prepeared Statements
|
||||||
|
* Binds params to values
|
||||||
|
* Returns rows and results
|
||||||
|
* credit: Traversy media
|
||||||
|
*/
|
||||||
|
class Database {
|
||||||
|
private $host = "localhost";
|
||||||
|
private $user = "DB_User";
|
||||||
|
private $pass = "DB_PASS";
|
||||||
|
private $dbname = "DB_NAME";
|
||||||
|
|
||||||
|
private $dbh;
|
||||||
|
private $error;
|
||||||
|
private $stmt;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
// Set DSN
|
||||||
|
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
|
||||||
|
$options = array (
|
||||||
|
PDO::ATTR_PERSISTENT => true,
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create a new PDO instanace
|
||||||
|
try {
|
||||||
|
$this->dbh = new PDO ($dsn, $this->user, $this->pass, $options);
|
||||||
|
} // Catch any errors
|
||||||
|
catch ( PDOException $e ) {
|
||||||
|
$this->error = $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare statement with query
|
||||||
|
public function query($query) {
|
||||||
|
$this->stmt = $this->dbh->prepare($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind values
|
||||||
|
public function bind($param, $value, $type = null) {
|
||||||
|
if (is_null ($type)) {
|
||||||
|
switch (true) {
|
||||||
|
case is_int ($value) :
|
||||||
|
$type = PDO::PARAM_INT;
|
||||||
|
break;
|
||||||
|
case is_bool ($value) :
|
||||||
|
$type = PDO::PARAM_BOOL;
|
||||||
|
break;
|
||||||
|
case is_null ($value) :
|
||||||
|
$type = PDO::PARAM_NULL;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
$type = PDO::PARAM_STR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->stmt->bindValue($param, $value, $type);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute the prepared statement
|
||||||
|
public function execute(){
|
||||||
|
return $this->stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get result set as Associative array
|
||||||
|
public function resultset(){
|
||||||
|
$this->execute();
|
||||||
|
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get single record as object
|
||||||
|
public function single(){
|
||||||
|
$this->execute();
|
||||||
|
return $this->stmt->fetch(PDO::FETCH_OBJ);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get record row count
|
||||||
|
public function rowCount(){
|
||||||
|
return $this->stmt->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the last inserted ID
|
||||||
|
public function lastInsertId(){
|
||||||
|
return $this->dbh->lastInsertId();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -185,7 +185,6 @@ width="" <!-- Describes the width of th
|
|||||||
<!-- Some other useful tags -->
|
<!-- Some other useful tags -->
|
||||||
|
|
||||||
<canvas></canvas> <!-- Allows to draw 2D shapes on the web page with the help of javascript -->
|
<canvas></canvas> <!-- Allows to draw 2D shapes on the web page with the help of javascript -->
|
||||||
<keygen> <!-- Represents a control for generating a public-private key pair -->
|
|
||||||
<map></map> <!-- Specifies an image map -->
|
<map></map> <!-- Specifies an image map -->
|
||||||
|
|
||||||
<!-- Collective Character Obejcts -->
|
<!-- Collective Character Obejcts -->
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ gu$ make lowercase until end of line
|
|||||||
<< indent line one column to left
|
<< indent line one column to left
|
||||||
== auto-indent current line
|
== auto-indent current line
|
||||||
ddp swap current line with next
|
ddp swap current line with next
|
||||||
ddkp swap current line with previous
|
ddkP swap current line with previous
|
||||||
:%retab fix spaces / tabs issues in whole file
|
:%retab fix spaces / tabs issues in whole file
|
||||||
:r [name] insert the file [name] below the cursor.
|
:r [name] insert the file [name] below the cursor.
|
||||||
:r !{cmd} execute {cmd} and insert its standard output below the cursor.
|
:r !{cmd} execute {cmd} and insert its standard output below the cursor.
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
- `Ctrl`+`Shift`+`P`, `F1`: Show Command Palette
|
- `Ctrl`+`Shift`+`P`, `F1`: Show Command Palette
|
||||||
|
- `Ctrl`+`Shift`+`T`: Open last closed tab
|
||||||
- `Ctrl`+`P`: Quick Open, Go to File
|
- `Ctrl`+`P`: Quick Open, Go to File
|
||||||
- `Ctrl`+`Shift`+`N`: New window/instance
|
- `Ctrl`+`Shift`+`N`: New window/instance
|
||||||
- `Ctrl`+`W`: Close window/instance
|
- `Ctrl`+`W`: Close window/instance
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
- `Ctrl`+`C`: Copy line (empty selection)
|
- `Ctrl`+`C`: Copy line (empty selection)
|
||||||
- `Ctrl`+`↓/↑`: Move line down / up
|
- `Ctrl`+`↓/↑`: Move line down / up
|
||||||
- `Ctrl`+`Shift`+`K`: Delete line
|
- `Ctrl`+`Shift`+`K`: Delete line
|
||||||
- `Ctrl`+`Enter` / `Ctrl`+`Shift`+`Enter`: Insert line below / above
|
- `Ctrl`+`Enter` / `Ctrl`+`Shift`+`Enter`: Insert line below / above
|
||||||
- `Ctrl`+`Shift`+`\`: Jump to matching bracket
|
- `Ctrl`+`Shift`+`\`: Jump to matching bracket
|
||||||
- `Ctrl`+`]` / `Ctrl`+`[`: Indent / Outdent line
|
- `Ctrl`+`]` / `Ctrl`+`[`: Indent / Outdent line
|
||||||
- `Ctrl`+`Home` / `End`: Go to beginning / end of file
|
- `Ctrl`+`Home` / `End`: Go to beginning / end of file
|
||||||
@@ -136,7 +137,7 @@
|
|||||||
|
|
||||||
- [`Wrap Console Log`](https://marketplace.visualstudio.com/items?itemName=midnightsyntax.vscode-wrap-console-log): Wrap to console.log by word or selection.
|
- [`Wrap Console Log`](https://marketplace.visualstudio.com/items?itemName=midnightsyntax.vscode-wrap-console-log): Wrap to console.log by word or selection.
|
||||||
|
|
||||||
- [`Bracket Pair Colorizer`](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer): Allows matching brackets to be identified with colours.
|
- [`Bracket Pair Colorizer`](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer): Allows matching brackets to be identified with colours.
|
||||||
|
|
||||||
## My Settings
|
## My Settings
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user