Skip to content

Instantly share code, notes, and snippets.

View pretty's full-sized avatar

Stefan Pretty pretty

View GitHub Profile
@martindrapeau
martindrapeau / jquery.cach-inputs.js
Created December 27, 2013 02:36
jQuery plugin to cache HTML inputs using local storage. Restores them upon next page load.
// Cache user inputs into HTML5 local storage. Restore them upon next page load.
// Usage:
// $('body').CacheInputs();
//
// Will store stringified JSON in local storage, against the key you specify
// or 'cache-inputs' if you omit it. See settings below.
//
// Author: Martin Drapeau
//
// Greatly inspired from Johnathan Schnittger
@zhouming
zhouming / MY_Session.php
Created September 8, 2012 05:51
Use redis in Codeigniter Session.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Session extends CI_Session{
private $sess_use_redis = TRUE;
private $redis = '';
public function __construct($params = array()) {
//parent::__construct();
$this->CI =& get_instance();
@fideloper
fideloper / config.app.php
Created July 18, 2012 18:26
Master-Slave database in CodeIgniter
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//Create a new config file
/*
|--------------------------------------------------------------------------
| Number of databases in use
|--------------------------------------------------------------------------
|
| Using a Master and Slave. The Slave doubles as a read-only database.
@sunny
sunny / decay.js
Created September 30, 2008 09:05
// Decay class, to call a callback less and less often. For example,
// make an Ajax request and freshen the decay only if the request has changed.
//
// To start the timeouts, call decay_object.start()
// To freshen up the speed of query, call decay_object.reset()
//
// Options:
// - seconds: time between each callback at the start and after a reset() (default 2)
// - decay: multiplier to use after each callback call (default 1.3)
// - max: maximum number of seconds to wait between each call (default 42)
@amboutwe
amboutwe / yoast_seo_meta_remove_dates.php
Last active October 5, 2020 08:39
Remove Date Meta Tags Output by Yoast SEO
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Date Meta Tags Output by Yoast SEO
* Credit: Yoast development team
* Last Tested: Apr 09 2019 using Yoast SEO 10.1.3 on WordPress 5.1.1
* For Yoast SEO 14.0 or newer, please see https://yoast.com/help/date-appears-search-results/#h-managing-dates
*/
add_action('wpseo_dc_'.'DC.date.issued', '__return_false'); // Premium versions 5.2 or older
@xeoncross
xeoncross / ParensParser.php
Created February 4, 2013 22:28
PHP: Nested Parenthesis Parser
<?php
// @rodneyrehm
// http://stackoverflow.com/a/7917979/99923
class ParensParser
{
// something to keep track of parens nesting
protected $stack = null;
// current level
protected $current = null;
@sproogen
sproogen / ChildComponent.vue
Last active July 30, 2021 02:40
Vee Validate - Child Component Example
<template>
<div>
<input v-validate data-rules="required" :class="{'has-error': errors.has("textInput")}" id="textInput" name="textInput" type="text">
<span class="error" v-show="errors.has("textInput")">{{ errors.first("textInput") }}</span>
</div>
</template>
<script>
import { find, propEq } from 'ramda'
import bus from './bus'
@tleen
tleen / gist:6395808
Created August 31, 2013 02:13
Javascript array of Canadian Provinces
['Alberta', 'British Columbia', 'Manitoba', 'New Brunswick', 'Newfoundland and Labrador', 'Northwest Territories', 'Nova Scotia', 'Nunavut', 'Ontario', 'Prince Edward Island', 'Quebec', 'Saskatchewan', 'Yukon Territory']
@emilysnothere
emilysnothere / add_action.php
Last active January 31, 2023 07:39
Adding fields to the WordPress post submit box
add_action('post_submitbox_misc_actions', createCustomField);
add_action('save_post', saveCustomField);
@dustinrecko
dustinrecko / worker.js
Created November 29, 2018 07:45
Cloudflare Worker Googlebot Tracking
const analyticsId = 'UA-xxxxxxxxx-x'
addEventListener('fetch', event => {
event.respondWith(handleRequest(event))
})
/**
* Check request object for Googlebot UA to send tracking data
* @param {Event} event
*/