Skip to content

Instantly share code, notes, and snippets.

@withremote
withremote / txplib_db.php
Created April 28, 2016 20:10
Drop in replacement to support Textpattern DB library past PHP 5.5.9
<?php
/**
* Class DB
*/
class DB
{
/**
* @var
*/
protected $config;
@withremote
withremote / Cache.php
Created March 13, 2013 17:34
codeigniter-cache delete_all()
/**
* Delete Full Cache or Cache subdir
* Skips .htaccess and index.htm(l) files for security
*
* @access public
* @param string
* @return void
*/
function delete_all($dirname = '')
{
@withremote
withremote / resize_iframe_js.misc.txp
Last active December 12, 2015 01:48
Iframe not auto expanding in IE8 or lower on XP
<iframe src="/somelocalfile.htm" frameborder="0" scrolling="no" width="100%" id="myIframe" class="auto-height"></iframe>
<script type="text/javascript" src="/js/libs/iframe-auto-height/jquery.iframe-auto-height.js"></script>
<script language="JavaScript">
jQuery('iframe.auto-height').iframeAutoHeight({
heightOffset: 10,
minHeight: 300
});
</script>
#!/usr/bin/env bash
# ===================================================
# Start Setup
# ===================================================
cd ~/
# Update yum
sudo yum -y update
# ===================================================
@withremote
withremote / get_selenium.sh
Created November 19, 2015 18:29
Get Selenium and Firefox for headless testing in vagrant box
#!/usr/bin/env bash
# Get Selenium and Firefox for headless testing in vagrant box
if [ ! -d "/var/selenium" ]; then
sudo mkdir /var/selenium
cd /var/selenium
sudo wget http://goo.gl/PJUZfa selenium-server-standalone.jar
fi
sudo yum -y install java-1.8.0-openjdk-headless.x86_64
sudo yum -y install firefox.x86_64
sudo yum -y install xorg-x11-server-Xvfb.x86_64
@withremote
withremote / gist:3034778
Created July 2, 2012 18:32
If String Contains
if(!function_exists('if_string_contains'))
{
function if_string_contains($needle,$haystack) {
if (is_array($needle)) {
$found_cout = 0;
foreach ($needle as $n) {
if (strlen(strstr($haystack,$n))>0) {
$found_cout++;
}
@withremote
withremote / GetMail.php
Created September 24, 2015 17:45
Get mail from a pop/imap email box
<?php
/*
* File: GetMail.php
* Description: Receiving mail With Attachments
*
* @package Pbc\Mail
* @author Mitul Koradia <mitulkoradia@gmail.com>
* @author Nate Nolting <naten@paulbunyan.net>
* @version: 1.1
*/
@withremote
withremote / MY_Session.php
Created January 8, 2015 15:20
Session library override if running tests
<?php
class MY_Session extends CI_Session {
protected $cliTestingDriver = 'codeception';
public function __construct(array $params = array())
{
parent::__construct($params);
@withremote
withremote / Session_codeception.php
Created January 8, 2015 15:18
CI3 flat file session driver used for testing with Codeception
<?php
/**
* CI3 flat file session driver used for testing with Codeception
*/
/**
* Class CI_Session_codeception
*/
class CI_Session_codeception extends CI_Session_driver
@withremote
withremote / txplib_misc.php
Created September 19, 2014 17:39
safe_strftime
// -------------------------------------------------------------
// Format a time, respecting the locale and local time zone,
// and make sure the output string is safe for UTF-8
function safe_strftime($format, $time='', $gmt=0, $override_locale='')
{
global $locale;
$old_locale = $locale;
if (!$time)
$time = time();