Skip to content

Instantly share code, notes, and snippets.

@shanecp
shanecp / backbone.views.common.js
Created March 28, 2014 05:19
BB: Backbone Pass options to the view
// Compatibility override - Backbone 1.1 got rid of the 'options' binding
// automatically to views in the constructor - we need to keep that.
// http://stackoverflow.com/questions/19325323/backbone-1-1-0-views-reading-options
Backbone.View = (function(View) {
return View.extend({
constructor: function(options) {
this.options = options || {};
View.apply(this, arguments);
}
});
@shanecp
shanecp / styles.css
Created March 30, 2014 02:08
CSS: Wordpress: Change Wordpress 2014 theme for full screen width
.entry-title {
text-transform: none;
}
.site-header,
.site {
max-width: 100%;
}
.site-content .entry-header, .site-content .entry-content, .site-content .entry-summary, .site-content .entry-meta, .page-content {
@shanecp
shanecp / functions.breadcrumbs.php
Created March 31, 2014 00:03
WP: Add breadcrumb navigation to wordpress posts
// http://www.qualitytuts.com/wordpress-custom-breadcrumbs-without-plugin/
function qt_custom_breadcrumbs() {
$showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show
$delimiter = '»'; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<span class="current">'; // tag before the current crumb
$after = '</span>'; // tag after the current crumb
@shanecp
shanecp / package.json
Created May 13, 2014 02:02
Sample Node config file for Grunt.js
{
"name": "[enter-your-project-name]",
"version": "0.0.0",
"description": "[Your project description.]",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
@shanecp
shanecp / Gruntfile.js
Created May 13, 2014 02:08
Sample Gruntfile.js to watch CSS/JS/PHP files for updates, concatenate and livereload them on a browser.
/*!
* [Enter your project name] Gruntfile
* http://example.com
* @author Shane Perera
*/
'use strict';
/**
* Grunt Module
@shanecp
shanecp / phpunit.xml
Created June 4, 2014 02:46
PHPUnit config file - Test configuration file for PHP
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailiure="false"
syntaxCheck="false">
<testsuites>
@shanecp
shanecp / countdownTimer.js
Created June 20, 2014 10:44
JS Countdown timer
$(document).ready(function() {
window.offerTimer = {};
offerTimer.offerEndTime = new Date(0);
offerTimer.offerEndTime.setUTCSeconds(#getEpoch(offerEndTime)#);
function formatNumber(number) {
number = number.toString();
if (number.length === 1) {
return '0' + number;
} else {
@shanecp
shanecp / directive.js
Last active August 29, 2015 14:03
Angular.js Directive Template
// this will look for an Attribute with 'em-checklist'
cix.directive('emChecklist', function() {
return {
// use Element, Attribute, Class or a combination
restrict: 'A',
// = both ways
// @ attribute
// &
@shanecp
shanecp / index.js
Last active August 29, 2015 14:10 — forked from stinoga/index.js
Replace a parameter in a query string
function paramReplace(name, string, value) {
// Find the param with regex
// Grab the first character in the returned string (should be ? or &)
// Replace our href string with our new value, passing on the name and delimeter
var re = new RegExp("[\\?&]" + name + "=([^&#]*)");
var matches = re.exec(string);
var newString;
if (matches === null) {
@shanecp
shanecp / gulpfile.js
Last active January 9, 2016 03:29
Laravel 5 Elixir with LiveReload custom task
// require the file
require('./gulp_tasks/watch');
// Call the new task in Laravel Elixir file
elixir(function(mix)) {
mix.watch();
});