Skip to content

Instantly share code, notes, and snippets.

View locvfx's full-sized avatar

Dylan Lopez locvfx

View GitHub Profile
@locvfx
locvfx / README.md
Created February 6, 2018 03:33 — forked from mikedfunk/README.md
CodeIgniter Pagination for Twitter Bootstrap

This uses Twitter Bootstrap classes for CodeIgniter pagination.

Drop this file into application/config.

@locvfx
locvfx / text
Created January 12, 2018 06:53
CodeIgniter - when to use get_instance()
If you are new to CodeIgniter you may be confused as to when you need to use get_instance and when you don't, it certainly tripped me up when I first came back to CodeIgniter after leaving the PHP community for some time.
Luckily it is pretty simple to remember.
If you are writing code that lives within a controller, a model or a view that is under CodeIgniter's control then you do not need to use get_instance.
If however you are writing your own custom libraries or something that sits outside of the MVC files then you do need to use it.
So, if you are inside a model you could do something like this;
@locvfx
locvfx / install_mariadb_columnstore_centos_7_2.md
Created January 12, 2018 05:42 — forked from dtheodor/ install_mariadb_columnstore_centos_7_2.md
Install MariaDB 1.08 Columnstore on Centos 7.2
@locvfx
locvfx / .htaccess
Created November 16, 2017 12:59
.htaccess file works with Vanish cache , serves content via https, should setup in root sub domain ex: https://images.domain.com
#Unset all Cookies!
Header unset Cookie
Header unset Set-Cookie
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
@locvfx
locvfx / .htaccess
Created November 16, 2017 11:59 — forked from dlueth/.htaccess
Unset all cookies via Apache .htaccess
Header unset Cookie
Header unset Set-Cookie
@locvfx
locvfx / .php
Last active November 15, 2017 15:03
Only allow certain country code, useful to protect admincp
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$url = "http://api.wipmania.com/".$ip;
$country = file_get_contents($url); //ISO code for Nigeria it is NG check your country ISO code
@locvfx
locvfx / .sh
Created November 14, 2017 15:03
Linux server info script
wget http://akamaras.com/bench.sh
sh bench.sh
@locvfx
locvfx / .php
Last active November 14, 2017 04:24
//Create a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
//Open a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //open file for writing ('w','r','a')...
//Read a File
$my_file = 'file.txt';
@locvfx
locvfx / .htaccess
Created November 11, 2017 06:08
Force https
# -----------------------Force https----------------------------------------------------------
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteOptions InheritDownBefore
# This prevents the rule from being overrided by .htaccess files in subdirectories.
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
@locvfx
locvfx / .php
Created November 7, 2017 11:10
PHP Clean up cache folder
function CleanUp_Cache_Folder(){
## Automatic cleanup Cache folder
$cache_folder = 'cache/';
$file_type = '*.mp3';
$files = glob($cache_folder.$file_type);
$time = time();
foreach ($files as $file)
if (is_file($file))
if ($time - filemtime($file) >= 60*60*24*1) // 1 days