Skip to content

Instantly share code, notes, and snippets.

Avatar

James Doyle james2doyle

View GitHub Profile
@james2doyle
james2doyle / ckeditor.toolbar.js
Created Aug 26, 2015
CKEDITOR Toolbar config
View ckeditor.toolbar.js
config.toolbar = 'Full';
config.toolbar_Full =
[
{ name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
{ name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton',
'HiddenField' ] },
'/',
@james2doyle
james2doyle / feed.xml
Created Aug 27, 2015
Example of an RSS Atom feed. Has images, author, and expanded entries.
View feed.xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Primer CMS</title>
<subtitle>Primer CMS is the new product from WARPAINT Media.</subtitle>
<link href="http://localhost:8888/warpaint-laravel-cms/public"></link>
<link href="http://localhost:8888/warpaint-laravel-cms/public/feed.xml" rel="self" />
<id>http://localhost:8888/warpaint-laravel-cms/public/</id>
<description>Primer CMS is the new product from WARPAINT Media.</description>
<updated>2015-08-27T15:10:58+00:00</updated>
<entry>
@james2doyle
james2doyle / filter.php
Last active Aug 29, 2015
Sanatize and filter $_GET and $_POST data that handles arrays and is recursive. http://goo.gl/Fonl6D
View filter.php
// Filters data against security risks.
function filter($data) {
if (is_array($data)) {
foreach ($data as $key => $element) {
$data[$key] = filter($element);
}
} else {
$data = trim(htmlentities(strip_tags($data)));
if(get_magic_quotes_gpc()) {
$data = stripslashes($data);
@james2doyle
james2doyle / $.fn.swappable.js
Created Feb 22, 2014
a small jquery plugin that causes elements to turn it into a input fields
View $.fn.swappable.js
$.fn.extend( {
swappable: function(options) {
this.defaults = {
id: 'swappable-temp-input',
class: 'swappable-input',
name: 'swappable-temp',
type: 'input',
evt: 'click',
end: 'blur',
detectTag: true,
@james2doyle
james2doyle / upload-file.php
Last active Aug 29, 2015
simple file upload handler with PHP
View upload-file.php
<?php
$ds = DIRECTORY_SEPARATOR;
$storeFolder = 'uploads';
function slugify($text) {
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
@james2doyle
james2doyle / image-list.php
Created Feb 22, 2014
list a folder of images and store the values in an array
View image-list.php
<?php
$images = array();
if ($handle = opendir('uploads')) {
while (false !== ($entry = readdir($handle))) {
$check = preg_match("/\.(jpg|jpeg|png|gif|webp)/i", $entry);
if ($entry != "." && $entry != ".." && $check) {
$alt = preg_replace('/\.(jpg|jpeg|png|gif|webp)/', '', $entry);
$image_info = getimagesize('uploads/'.$entry);
$images[] = array(
@james2doyle
james2doyle / replace-css-vars.d
Created Mar 3, 2014
A small script written in D that replaces LESS style variables in a file.
View replace-css-vars.d
// compile with: gdmd -O -inline -release -noboundscheck replace-css-vars.d
// usage: ./replace-css-vars text.less
import std.stdio, std.file, std.regex, std.string;
string FILE;
// empty a line
string clearLine(string content, string subject) {
auto com = regex(subject, "g");
auto newcontent = replaceAll(content, com, "");
@james2doyle
james2doyle / loadScript.js
Created Mar 15, 2014
loadScript. Async load a script and then fire a callback when loaded.
View loadScript.js
//this function will work cross-browser for loading scripts asynchronously
function loadScript(src, callback) {
var s,
r,
t;
r = false;
s = document.createElement('script');
s.type = 'text/javascript';
s.src = src;
s.onload = s.onreadystatechange = function() {
@james2doyle
james2doyle / Cronjob.txt
Created Mar 26, 2014
Syntax for running cron jobs
View Cronjob.txt
# min (0-59), hour (0-23), DOM (1-31), MOY (1-12), DOW (0-6 with 0=Sunday).
# the following will clear the Apache error log at one minute past midnight each day.
01 00 * * * echo "" > /www/apache/logs/error_log
@james2doyle
james2doyle / window.pyro.js
Created Mar 26, 2014
A simple header script of using in PyroCMS sites. Exposes some site data for use in javascript
View window.pyro.js
window.pyro = {
base_url: "{{ url:base }}",
current_url: "{{ url:current }}",
layout: "{{ page:layout:slug }}",
segement: "{{ url:segments segment="1" }}",
module: "{{ global:module }}"
};