Skip to content

Instantly share code, notes, and snippets.

View vik407's full-sized avatar
👋
Hello there

Víctor Hugo Hernández vik407

👋
Hello there
View GitHub Profile
@vik407
vik407 / admin-access.conf
Created December 29, 2021 00:16
Nginx - Whitelist IPs to access a url
location /admin {
error_page 403 = @deny; // Return forbidden and redirect
allow 127.0.0.1;
allow 192.168.0.1;
deny all;
try_files $uri $uri/ /index.php?$query_string; // Important for PHP rewrite cond ej (index.php/admin)
}
location @deny {
return 301 http://example.com; // The redirect URL
@vik407
vik407 / BlockIpMiddleware.php
Created December 28, 2021 14:41
Laravel - Voyager, whitelist ips to access the Admin
<?php
namespace App\Http\Middleware;
use Closure;
class BlockIpMiddleware
{
// set IP addresses
public $allowIps = ['127.0.0.1', '192.168.0.1', '127.0.0.1'];
/**
* Handle an incoming request.
@vik407
vik407 / 0_strings.rb
Last active September 9, 2021 20:43
Ruby 💎
#!/usr/bin/env ruby
p "Enter your first name:"
first_name = gets.chomp
p "Enter your last name"
last_name = gets.chomp
#variable interpolation
full_name = "#{first_name} #{last_name}"
@vik407
vik407 / gitignore_per_git_branch.md
Created July 14, 2020 17:24 — forked from wizioo/gitignore_per_git_branch.md
HowTo have specific .gitignore for each git branch

How to have specific .gitignore for each git branch

Objective

My objective is to have some production files ignored on specific branches. Git doesn't allow to do it.

Solution

My solution is to make a general .gitignore file and add .gitignore.branch_name files for the branches I want to add specific file exclusion. I'll use post-checkout hook to copy those .gitignore.branch_name in place of .git/info/exclude each time I go to the branch with git checkout branch_name.

@vik407
vik407 / container_git.sh
Last active April 8, 2021 20:03
Holberton pieces of code
#!/usr/bin/env bash
# A setup script to start working on remote machines
apt-get update
# apt-get install -y emacs git // Some HBTN Containers doesn't have it preinstalled!
git config --global color.ui true
git config --global user.name "Juan Perez"
git config --global user.email [email protected]
git config --global credential.helper cache --timeout=3600
cat >> ~/.ssh/id_rsa << EOF
# Put your key here!
@vik407
vik407 / Vagrantfile
Created March 28, 2020 15:40
Vagrant Box MySQL Ubuntu Bionic
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Ubuntu version 18 LTS
config.vm.box = "ubuntu/bionic64"
# Forward ports
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3306, host: 33306
@vik407
vik407 / Vagrant Ubuntu 14.04 MySQL - PHPMyAdmin
Created March 28, 2020 02:15
Vagrant MySQL - Ubuntu 14.04
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get install mariadb-server phpmyadmin
# - - -
# Vagrant edit vagrantfile
# config.vm.network "forwarded_port", guest: 80, host: 8080
# config.vm.network "forwarded_port", guest: 3306, host: 3306
# - - -
# my.cnf edit file to fix the loopback error (localhost)
# sudo nano /etc/mysql/my.cnf