Skip to content

Instantly share code, notes, and snippets.

@shanecp
shanecp / git
Created August 8, 2015 13:42
Clone GIT repo to your current directory
git clone your-repo tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
@shanecp
shanecp / implode.js
Created March 31, 2015 06:02
LoDash - extension for implode (similar to PHP function)
_.mixin({
implode: function (glue, collection) {
glue = glue || '';
if (!_.isArray(collection)) return false;
if (collection.length == 1) return collection[0];
var returnString = '';
@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();
});
@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 / 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 / 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 / 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 / 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 / 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 / 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 = '&raquo;'; // 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