Skip to content

Instantly share code, notes, and snippets.

View sahibalejandro's full-sized avatar
😎
Doing cool stuff!

Sahib sahibalejandro

😎
Doing cool stuff!
View GitHub Profile
@sahibalejandro
sahibalejandro / deploy.sh
Last active January 8, 2024 17:48
Deploy script for Laravel projects.
# Shutdown the laravel app
php artisan down
# Install new composer packages
composer install --no-dev --prefer-dist
# Cache boost configuration and routes
php artisan cache:clear
php artisan config:cache
php artisan route:cache
@sahibalejandro
sahibalejandro / script.sh
Last active September 13, 2023 06:38
Generate PFX file from Let's Encrypt PEM files for Azure Application Service
# STEP 1
# Frist, generate PEM files using certbot docker image
docker run --rm -it -v ".:/etc/letsencrypt" certbot/certbot certonly --manual --preferred-challenges dns -d "domain.com" -d "*.domain.com"
# Follow the certbot instructions
# Remember that multiple TXT records with the same host are allowed
# so you can add TXT record for naked and wildcard validations.
# STEP 2
# Generate FPX file using Ubuntu docker image
@sahibalejandro
sahibalejandro / MakeViewCommand.php
Created April 13, 2015 04:45
Laravel Command make:view
<?php namespace Sahib\Generators\Commands;
use File;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
/**
* Class MakeViewCommand
* @package Sahib\Generators\Commands
*/
@sahibalejandro
sahibalejandro / csrf-token.js
Created November 1, 2015 09:03
Get csrf token form meta tag
export default () => {
return document.querySelector('meta[name="csrf-token"]').getAttribute('content');
};
@sahibalejandro
sahibalejandro / RfcValidator.php
Last active June 29, 2021 23:31
Laravel's RFC Validator
<?php
/**
* @author Sahib J. Leo <sahib@sahib.io>
* Date: 11/24/15 8:53 AM
*/
namespace App\Validation;
class RfcValidator
{
@sahibalejandro
sahibalejandro / addBusinessTime.js
Created August 31, 2019 08:20
Business Time Challenge
function addBusinessTime(holiday, time, duration) {
let finalTime = new Date(time.getTime());
finalTime.setSeconds(finalTime.getSeconds() + duration);
// First lets cover all possible cases when the start time is before the
// holiday start.
if (time.getTime() <= holiday.start.getTime()) {
// If duration is negative or final time still before the holiday starts
// then there is nothing to do, simply return the final time.
if (duration <= 0 || (finalTime.getTime() <= holiday.start.getTime())) {
@sahibalejandro
sahibalejandro / init.vim
Last active October 17, 2018 04:42
nvim config file
call plug#begin()
" Editing
Plug 'mattn/emmet-vim'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
Plug 'easymotion/vim-easymotion'
Plug 'sgur/vim-editorconfig'
" Code completion
Plug 'sahibalejandro/vim-php'
@sahibalejandro
sahibalejandro / vue-form-object-custom-axios.js
Created October 1, 2018 16:13
Form Object: Attach custom axios instance.
import axios from 'axios';
import Form from 'form-object';
axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
Form.defaults.axios = axios;
<!-- Assign a class when the error is present -->
<input type="email" v-model="user.email" :class="{ 'has-error': form.errors.has('email') }" />
<!-- Display the error message when it's present -->
<p class="error" v-show="form.errors.has('email')" v-text="form.errors.get('email')"></p>
<div class="progress">
<div class"progress-bar" :style="{ width: form.progress + '%' }"></div>
</div>