Skip to content

Instantly share code, notes, and snippets.

View adamtester's full-sized avatar
💻
Coding

Adam Tester adamtester

💻
Coding
View GitHub Profile
@adamtester
adamtester / MY_Parser.php
Created May 9, 2013 08:35
Extends the CI Parser class to allow for language files to be parsed. With this instead of using <?php echo $this->lang->line('lineoftext'); ?> You can now use an underscore in your view files like so: {_lineoftext}. Enjoy cleaner view files!
<?php
/*
******************************************************************************
// Extends the CI Parser class to allow for language files to be parsed.
// With this instead of using <?php echo $this->lang->line('lineoftext'); ?>
// You can now use an underscore in your view files like so: {_lineoftext}
// Enjoy cleaner view files!
// Place this file in application/libraries/MY_Parser.php
******************************************************************************
@adamtester
adamtester / page.html
Created May 10, 2013 08:58
Allows printing of another page without reloading or using ajax, should work in all browsers and as the frame is loaded after the W3 validator won't moan.
<div class="print_retroplan_div" id="print_retroplan_div" style="display:none;"></div>
@adamtester
adamtester / OutsideCI.php
Created April 8, 2014 16:00
Using CodeIgniter files outside the CI installation
<?php
ob_start();
include('index.php');
ob_end_clean();
$CI =& get_instance();
$CI->load->library('session');
echo $CI->session->userdata('name');
/*
Credit to Ben Swinburne
if (!function_exists('make_slug'))
{
function make_slug($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
@adamtester
adamtester / ci_compress.php
Last active August 29, 2015 14:13
Compress script for CodeIgniter
function compress()
{
ini_set("pcre.recursion_limit", "16777");
$CI =& get_instance();
$CI->benchmark->mark('compression_start');
// Set output type
$CI->output->set_header('Content-type: text/html; charset=utf-8');
$buffer = $CI->output->get_output();
@adamtester
adamtester / laravel_compress.php
Created January 15, 2015 11:16
laravel_compress
App::after(function($request, $response)
{
// Compress output
ini_set("pcre.recursion_limit", "16777");
$buffer = $response->getContent();
$re = '%# Collapse whitespace everywhere but in blacklisted elements.
(?> # Match all whitespans other than single space.
[^\S ]\s* # Either one [\t\r\n\f\v] and zero or more ws,
| \s{2,} # or two or more consecutive-any-whitespace.
) # Note: The remaining regex consumes no text at all...
@adamtester
adamtester / Slug.php
Created July 6, 2015 13:36
Laravel unique slug generator
<?php namespace App\Libraries;
use DB;
class Slug {
// Create a unique slug
static function make($name, $table = null, $column = null)
{
$valid = false;
@adamtester
adamtester / GetLevel
Created July 20, 2015 09:44
Code for the levelling system for Vevvu Platform
function getLevels($cEXP) {
for($i = 1; ($i * $i + 2) * $i <= $cEXP; $i++);
return $i;
}
@adamtester
adamtester / wkhtmltopdf.sh
Last active April 12, 2019 16:58
Install wkhtmltopdf on Ubuntu 14.04+
wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo apt-get update
sudo apt-get install wkhtmltox
sudo apt-get -f install
sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
wkhtmltopdf -V
rm wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
@adamtester
adamtester / script.sh
Created April 15, 2016 09:37
Bypassing the memory check on a VMware ESXi 6
# Modified version of
# http://dtucker.co.uk/hack/bypassing-the-memory-check-on-a-vmware-esxi-5.html
# Boot the system from USB Stick / CD with ESXi installer on it.
# Once the installer welcome screen shows up, press ALT+F1
# Login as "root", no password.
cd /usr/lib/vmware/weasel/util
mv upgrade_precheck.pyc upgrade_precheck.pyc.old
cp upgrade_precheck.py upgrade_precheck.py.old
chmod 666 upgrade_precheck.py.old