Skip to content

Instantly share code, notes, and snippets.

@introwit
introwit / helper.php
Created October 28, 2015 10:56
Display Greetings (Morning/Evening)
<?php
/* This sets the $time variable to the current hour in the 24 hour clock format */
$time = date("H");
/* Set the $timezone variable to become the current timezone */
$timezone = date("e");
/* If the time is less than 1200 hours, show good morning */
if ($time < "12") {
echo "Good morning";
} else
/* If the time is grater than or equal to 1200 hours, but less than 1700 hours, so good afternoon */
@introwit
introwit / forgeLikeServerSetup.md
Last active October 21, 2022 08:48
Personally written version of Chris Fidao's video on setting up a Forge like server

Let's Log in!

  • Create ssh pair for login on a fresh DO droplet.
  • ssh into the server
  • apt-get update It updates server's knowledgeable packages. Not technically updates any software.

Alright, let's start installing our stuff boys!

  • apt-get install -y git tmux vim curl wget zip unzip htop -y flag to say yes to all prompts
  • Adding additional repositories so that we can get latest version of the softwares from this respective repositories of them:
  • For NGINX: add-apt-repository -y ppa:nginx/development (Development branch of nginx repo is actually what they consider stable because its stable + bug-fixes, its not exactly the dev branch)
  • For PHP: add-apt-repository -y ppa:ondrej/php
@introwit
introwit / verification.blade.php
Created October 11, 2016 15:41
Email verification blog - part 4
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css" rel="stylesheet" media="all">
/* Media Queries */
@media only screen and (max-width: 500px) {
@introwit
introwit / RegisterController2.php
Last active May 3, 2017 00:00
Email verification blog - gist 2
<?php
/**
* Over-ridden the register method from the "RegistersUsers" trait
* Remember to take care while upgrading laravel
*/
public function register(Request $request)
{
// Laravel validation
$validator = $this->validator($request->all());
<?php
public function credentials(Request $request)
{
return [
'email' => $request->email,
'password' => $request->password,
'verified' => 1,
];
}
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
@introwit
introwit / RegisterControllerVerify.php
Last active October 18, 2016 10:15
Email verification blog - Part 5
<?php
// Get the user who has the same token and change his/her status to verified i.e. 1
public function verify($token)
{
// The verified method has been added to the user model and chained here
// for better readability
User::where('email_token',$token)->firstOrFail()->verified();
return redirect('login');
<?php
namespace App\Http\Controllers\Auth;
use DB;
use Mail;
use App\User;
use Validator;
use Illuminate\Http\Request;
use App\Mail\EmailVerification;
@introwit
introwit / RegisterController.php
Last active October 11, 2016 16:38
Email verification blog - gist 1
<?php
/**
* Create a new user instance after a valid registration with a random email token
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
@introwit
introwit / EmailVerification.php
Last active October 11, 2016 16:37
Email verification blog - gist 3
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;