Skip to content

Instantly share code, notes, and snippets.

View walkerdigital's full-sized avatar

Walker Digital walkerdigital

View GitHub Profile
@walkerdigital
walkerdigital / Template.vue
Created September 24, 2019 15:44
Vue Single File Component Template
<template>
</template>
<script>
export default {
}
</script>
<style lang="scss">
@walkerdigital
walkerdigital / emailValidation.js
Created September 13, 2019 15:38
JavaScript Email Validation
function emailIsValid (email) {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
}
@walkerdigital
walkerdigital / sanitize.sql
Created January 12, 2018 16:07
Clean MySQL field of hidden formatting / characters (ie. Microsoft Word)
UPDATE `table` SET `field` = CONVERT(BINARY CONVERT(`field` USING latin1) USING utf8);
@walkerdigital
walkerdigital / Code Igniter INSERT IGNORE
Created November 29, 2017 16:47
Code Igniter INSERT IGNORE INTO
$data = array(
'title' => 'My title',
'name' => 'My Name',
'date' => 'My date'
);
$sql = $this->db->set($data)->get_compiled_insert('mytable');
echo $sql;
@walkerdigital
walkerdigital / .htaccess
Created March 25, 2017 01:57
.htaccess snippets
# REMOVE WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]
# PREVENT HOTLINKING
RewriteEngine On
#Replace ?mysite\.com/ with your blog url
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
@walkerdigital
walkerdigital / states.php
Created November 10, 2016 16:45
US States Array PHP
$states = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
'CA'=>'CALIFORNIA',
'CO'=>'COLORADO',
'CT'=>'CONNECTICUT',
'DE'=>'DELAWARE',
'FL'=>'FLORIDA',
@walkerdigital
walkerdigital / json_output.php
Created October 23, 2016 19:52
CodeIgniter - Output Class - JSON
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('foo' => 'bar')));
@walkerdigital
walkerdigital / .htaccess
Created October 23, 2016 01:37
CodeIgniter - simple htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
@walkerdigital
walkerdigital / Default_model.php
Created October 22, 2016 23:03
A blank default model used in CodeIgniter.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pages_model extends CI_Model {
public $variable;
public function __construct()
{
parent::__construct();
$this->load->database();
@walkerdigital
walkerdigital / gist:d94aabdfad94091f65322b656d9aac06
Last active October 22, 2016 22:48
Codeigniter - Default Controller Construct
public function __construct()
{
parent::__construct();
$this->load->model(array());
$this->load->helper(array());
$this->load->library(array());
$this->data = [];
}