Skip to content

Instantly share code, notes, and snippets.

View sarkarshuvojit's full-sized avatar
🌀

Shuvojit Sarkar sarkarshuvojit

🌀
View GitHub Profile
@sarkarshuvojit
sarkarshuvojit / gist:e70392623395b2939c143c0c15925842
Created September 24, 2018 07:22
Ubuntu 18.04 Lamp Setup Mysql password rest
sudo mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test';
@sarkarshuvojit
sarkarshuvojit / QueryLog.php
Created January 19, 2018 05:53
Log all queries in a log file - Laravel
<?php
namespace App\Http\Middleware;
use Closure;
class QueryLog
{
/**
* Handle an incoming request.
@sarkarshuvojit
sarkarshuvojit / regex.js
Created January 12, 2018 13:10
Email Regex for Javascript
user_email.trim().length==0 || user_email.match(/^[\w!#$%&\'*+\/=?^`{|}~.-]+@(?:[a-z\d][a-z\d-]*(?:\.[a-z\d][a-z\d-]*)?)+\.(?:[a-z][a-z\d-]+)$/i) == null
<?php
include 'conn.php';
include 'helper.php';
include 'and_many_more.php';
@sarkarshuvojit
sarkarshuvojit / conn.php
Last active December 6, 2017 20:51
Blog demo code
<?php
// connect to database
$con = mysqli_connect('host', 'user', 'password', 'db_name');
// check for connection errors
if(mysqli_connect_errno())
die(mysqli_connect_error());
// function to execute query and automatically check for errors
function query($sql){
@sarkarshuvojit
sarkarshuvojit / index-revised.php
Last active December 6, 2017 20:35
Sample code
<?php include_once 'helper/helper.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Website</title>
@sarkarshuvojit
sarkarshuvojit / helper.php
Last active December 6, 2017 20:51
Maintain core php project sample code
<?php
function subview($file){
$file = __DIR__.'/../views/sub-views/'.$file;
include $file;
}
@sarkarshuvojit
sarkarshuvojit / index.php
Last active December 6, 2017 20:33
Structure Core PHP Sample Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Website</title>
</head>
@sarkarshuvojit
sarkarshuvojit / validate.js
Last active December 5, 2017 00:18
Art of Laziness — Form Validation JS
$(document).ready(function(){
// invoke function when form is submit
$("#form-name").submit(function(e){
// select all the input fields with form-validate class and loop over them
$(".form-validate").each(function () {
// check if the the form is empty/filled with spaces
if($(this).val().trim().length == 0){
// get the respective data-validation-error
var errorMessage = $(this).attr('data-validation-error');
// show the error message somehow
@sarkarshuvojit
sarkarshuvojit / form.html
Last active December 4, 2017 23:58
Art of Laziness — Form Validation HTML
...
<div class="form-group">
<input type="text" class="form-control form-validate" placeholder="Your First Name" data-error-message="Please enter your name">
</div>
<div class="form-group">
<input type="text" class="form-control form-validate" placeholder="Your Last Name" data-error-message="Please enter your surname">
</div>
...
...
<div class="form-group">