Skip to content

Commit dac0aae

Browse files
committed
massive refactoring
1 parent 23e261f commit dac0aae

File tree

332 files changed

+6597
-644
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

332 files changed

+6597
-644
lines changed

bash/activate-a-virtual-environment-via-bash.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

bash/bulk-encrpty-directory-copy-to-other-gpg.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

bash/run-a-script-if-it-is-not-already-running-using-bash.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

bootstrap/display-two-elementss-side-by-side-in-bootstrap.md

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
author: "Saqib Razzaq"
3+
title: "How to activate a virtual environment via Bash"
4+
date: "2021-11-11"
5+
description: "In some cases, you might want to activate a virtual env without any manual input. This is how it can be achieved."
6+
tags: ["bash", "linux"]
7+
ShowToc: true
8+
TocOpen: true
9+
---
10+
11+
1. Create a file named `anything.sh` and make it executable
12+
2. Paste following code in file
13+
3. Run `./path-to-file.sh`
14+
15+
`cd path/to/env/dir && source bin/activate`

laravel/add-a-user-middleware-in-laravel.md renamed to content/posts/add-a-user-middleware-in-laravel.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
### How to add a user middleware in Laravel
1+
---
2+
author: "Saqib Razzaq"
3+
title: "How to add a user middleware in Laravel"
4+
date: "2021-03-17"
5+
tags: ["php", "laravel"]
6+
ShowToc: true
7+
TocOpen: true
8+
---
29

310
I was building an API. I had already used `auth:api` middleware. I was sure that a user was logged in. However, I wanted to protect some of my routes further by only allowing an admin to access them. I was using `level` field in `users` table. A level `1` meant it was an admin. Hence, I created an `Admin` middleware to do what I had in mind. Here is how it can be done.
411

@@ -7,7 +14,7 @@ I was building an API. I had already used `auth:api` middleware. I was sure that
714

815
2. Open `app\Http\Middleware\Middlewarename.php`
916
3. Then paste following code in `handle()` function
10-
```
17+
```php
1118
// ->level can be any field you like
1219
if (\Auth::user()->level === 1) {
1320
return $next($request);

laravel/add-helper-files-in-laravel.md renamed to content/posts/add-helper-files-in-laravel.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
### How to add helper files in Laravel
1+
---
2+
author: "Saqib Razzaq"
3+
title: "How to add helper files in Laravel"
4+
date: "2021-03-17"
5+
tags: ["php", "laravel"]
6+
ShowToc: true
7+
TocOpen: true
8+
---
29

310
There are some cases when you need to add your own custom functions in Laravel. I often have my own custom helpers for speeding up development. You can easily add your own files by following this quick guide.
411

512
1. Create a folder in `app\Http` folder. Let's assume you created `Helpers`
613
2. You can place any number of `php` files in this directory.
714
3. Then open `composer.json` found in your root directory and find
815

9-
```
16+
```json
1017
"autoload-dev": {
1118
"psr-4": {
1219
"Tests\\": "tests/"
@@ -15,7 +22,7 @@ There are some cases when you need to add your own custom functions in Laravel.
1522
```
1623
4. Then replace it so it looks like this
1724

18-
```
25+
```json
1926
"autoload-dev": {
2027
"psr-4": {
2128
"Tests\\": "tests/"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
author: "Saqib Razzaq"
3+
title: "Apache - Download password protected file"
4+
date: "2019-03-11"
5+
tags: ["bash"]
6+
ShowToc: true
7+
TocOpen: true
8+
---
9+
10+
`wget --password=pass_here --user=user_name_here file_to_download`

bash/zip-all-files-in-directory-and-send-to-another-server.md renamed to content/posts/bash-zip-files-send-to-another-server.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
### How to ZIP all files in directory and send to another server
2-
3-
First install `zip` if not already install
4-
5-
Ubuntu `apt-get install zip`
6-
Centos `yum install zip`
7-
8-
Then create a `file.sh` and paste following code
9-
10-
```
11-
OUTFILE=outputfile.zip
12-
INPUTDIR=inputdir
13-
zip -R $OUTFILE $INPUTDIR
14-
scp $OUTFILE usrename@outserver:/path/of/ $OUTFILE -i key.pem
1+
---
2+
author: "Saqib Razzaq"
3+
title: "Bash - ZIP all files in directory and send to another server"
4+
date: "2020-12-29"
5+
tags: ["bash"]
6+
ShowToc: true
7+
TocOpen: true
8+
---
9+
10+
First install `zip` if not already install
11+
12+
Ubuntu `apt-get install zip`
13+
Centos `yum install zip`
14+
15+
Then create a `file.sh` and paste following code
16+
17+
```bash
18+
OUTFILE=outputfile.zip
19+
INPUTDIR=inputdir
20+
zip -R $OUTFILE $INPUTDIR
21+
scp $OUTFILE usrename@outserver:/path/of/ $OUTFILE -i key.pem
1522
```

bootstrap/center-any-element-in-bootstrap.md renamed to content/posts/center-any-element-in-bootstrap.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
---
2+
author: "Saqib Razzaq"
3+
title: "How to center any element in Boostrap 3"
4+
date: "2019-01-19"
5+
tags: ["bootstrap"]
6+
ShowToc: true
7+
TocOpen: true
8+
---
9+
110
Following method can be used to center any element. It comes really handy when building pagination buttons that are generally place at the bottom of page right in the middle.
211

3-
```
12+
```html
413
<div class="text-center">
514
<button class="btn btn-primary"></button>
615
</div>

0 commit comments

Comments
 (0)