Skip to content

Instantly share code, notes, and snippets.

View baorv's full-sized avatar
🎯
Focusing

Bob Roan baorv

🎯
Focusing
  • Mageplaza
  • Hanoi, Vietnam
View GitHub Profile
<?php
// You may need to use this classes
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Pagination\Paginator;
// Searching in segments Model, with pagination, ordering, sorting and searching.
$segments = Segment::where('segmentProviderName', $provider); // first where condition
$segmentStatuses = config('constants.segment.status');
@baorv
baorv / install virtualenv ubuntu 16.04.md
Created March 22, 2018 09:22 — forked from Geoyi/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv 
@baorv
baorv / install-php7.2-mcrypt.sh
Created April 24, 2018 03:35 — forked from arzzen/install-php7.2-mcrypt.sh
Install PHP 7.2 MCrypt extension
#
# Check version php and pecl
#
php -v # if default php is not 7.2 then use /usr/bin/php7.2 instead php
pecl version
#
# Install mcrypt extension
# see http://pecl.php.net/package-info.php?package=mcrypt&version=1.0.1
#
@baorv
baorv / postfix-dovecot-ubuntu14.04.sh
Created May 4, 2018 05:15 — forked from haisum/postfix-dovecot-ubuntu14.04.sh
Automated bash script to setup dovecot postfix mysql email server on ubuntu 14.04
#!/usr/bin/env bash
#####
# Script to install postfix
#####
DOMAIN="example.com"
EMAIL="haisum@example.com"
PASSWORD="example.com1*"
@baorv
baorv / centos_mail_bootstrap.sh
Created May 4, 2018 06:19 — forked from cou929/centos_mail_bootstrap.sh
Postfix and dovecot setup script for CentOS (instead of sendmail)
#! /bin/sh
# postfix and dovecot setup script (instead of sendmail)
# based on http://centossrv.com/postfix.shtml
echo "### install postfix via yum if not exist"
if [ ! -e /etc/postfix/main.cf ]
then
sudo yum -y install postfix
else
@baorv
baorv / CheckForMaintenanceMode.php
Created May 7, 2018 07:57 — forked from harini-ua/CheckForMaintenanceMode.php
Custom middleware Laravel 5 check for maintenance mode.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Routing\Route;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Original;
@baorv
baorv / 01-directory-structure.md
Created July 5, 2018 04:45 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@baorv
baorv / search-form.js
Created July 23, 2018 10:48 — forked from awojtczyk/search-form.js
Shopify ajax search
$(function() {
var currentAjaxRequest = null;
var searchForms = $('form[action="/search"]').css('position', 'relative').each(function() {
var input = $(this).find('input[name="q"]');
input.attr('autocomplete', 'off').bind('keyup change', function() {
var term = $(this).val();
var form = $(this).closest('form');
var searchURL = '/search?type=product&q=*' + term + '*';
var resultsList = $('.search-results');
resultsList.perfectScrollbar({
@baorv
baorv / axios-401-response-interceptor.js
Created August 4, 2018 05:58 — forked from yajra/axios-401-response-interceptor.js
Axios 401 response interceptor.
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@baorv
baorv / gist:15d2085643a11369da5660c8bdd13a5b
Created August 6, 2018 06:59 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: