Skip to content

Instantly share code, notes, and snippets.

View danrichards's full-sized avatar
🎯
Focusing

Dan Richards danrichards

🎯
Focusing
View GitHub Profile
@danrichards
danrichards / $.alert.js
Last active February 21, 2016 04:48
jQuery / Handlebars alert plugin for Bootstrap.
/**
* @author Dan Richards <[email protected]>
*
* Assumes a compiled handlebars template is available.
* @see http://handlebarsjs.com/precompilation.html
*/
(function ($) {
$.extend({
alert: function(message, params) {
var alertContainer = $('#alerts');
@danrichards
danrichards / _.default.js
Last active February 21, 2016 04:46
_.default(value, default_val) Provide a default value if param is undefined or null.
/**
* Use default vlaue
*/
_.mixin({
default: function(value, default_val) {
if (value === null && typeof value === "object") {
return default_val;
}
return _.isUndefined(value) || _.isNull(value) ? default_val : value;
}
@danrichards
danrichards / laravel-model-unique-slug.php
Last active December 20, 2015 21:24
Retrieve a unique slug with your Laravel model.
/**
* Find a unique slug.
*
* @see https://github.com/cocur/slugify
* @param $text
*
* @return string
*/
public static function getUniqueSlug($text)
{
@danrichards
danrichards / .profile
Last active August 29, 2015 14:27 — forked from tamlyn/.profile
Configs for our command line tools
# Console2 Settings can be reached by pressing Ctrl + Alt + S
# Use nano instead of vim
EDITOR=nano
# always list in long format
alias ls='ls -la --color'
# set dynamic prompt and window/tab title
PS1='\[\e]0;${PWD##*/}\a\]\n' # set window title
@danrichards
danrichards / .danrc
Last active March 12, 2019 19:26
Productive .bashrc file for your BITNAMI LAMP server. (using with Amazon AMI-7679c91e)
# ------------------------------------------------------------------
# IF YOU EDIT THIS FILE OUTSIDE OF THE SERVER, BE SURE YOUR LINE
# ENDINGS ARE SET TO UNIX. SublimeText2 > View > Line Endings > Unix
# ------------------------------------------------------------------
# Put .danrc into the same folder as your .bashrc file
# Typically, this is /home/username/
# $ sudo nano /home/username/.bashrc
# Include in your .bashrc file
# source .danrc
# -----------------------------------------------------------------