Skip to content

Instantly share code, notes, and snippets.

@piercemoore
piercemoore / notification_increment.js
Created January 21, 2013 23:04
Increment Notification count
$(function() {
var badge_unreadMessages = $("#unread_message_count");
// Script to check for notifications runs
// If the script comes back with new notifications:
badge_unreadMessages.text( parseInt( badge_unreadMessages.text() ) + 1 );
});
@piercemoore
piercemoore / Handlebars.html
Last active December 11, 2015 16:08
Comparison of HTML structure to Handlebars template
<script type="x-handlebars-template" id="messages_messageListItem">
<div class="list">
<div class="sub">
<div class="subject">
{{subject}}
</div>
<div class="notification">
{{unread}}
</div>
<div class="message">
@piercemoore
piercemoore / ProfanityCounter.sh
Created January 30, 2013 23:13
A command to see how much profanity your team has used in all the commit messages for a repository.
git log --pretty=format:'%s' | tr '[:upper:]' '[:lower:]' | tr '[:space:]' '\n' | sort | uniq -c | sort -nr | grep -iE "(fuck|shit|bitch|damn|hate|ugly|stupid|asshole|moron|eff|worthless|piss)"
@piercemoore
piercemoore / JavascriptBenchmarkUsage.html
Last active December 12, 2015 07:58
This set of functions, when placed in the correct places, will help you find bottlenecks without having to dive into Chrome's Inspector or Mozilla's Firebug.
<html>
<head>
// Blah Blah Blah
</head>
<body>
<script type="text/javascript">
/**
* We make absolutely positive that the first thing on the stack is our timer starting.
*/
// And away we go!
@piercemoore
piercemoore / Default.sublime-keymap.json
Last active December 14, 2015 04:29
Helpful Sublime Text keymappings and settings
[
{
"keys": [
"alt+g"
],
"command": "toggle_setting",
"args": {
"setting": "gutter"
}
},
@piercemoore
piercemoore / TrimWhitespace.js
Last active December 14, 2015 18:19
Trim ALL tabs, newlines, and unnecessary whitespace from a string in Javascript, simple extension to the String prototype
// For the purposes of this gist, assume we have declared the variable str and it is actually a string.
var str = "This is my awesome string. \n I love strings. \n\t\t\t Stringy string string! \n\t\t\t\tWhat??";
// Regex to remove all tabs and newlines.
str = str.replace(/[\t]|[\n]/gm, '');
// Regex to replace all sets of 2 or more space characters with a single space
str = str.replace(/\s{2,}/g, ' ');
// Regex to remove all HTML comments
@piercemoore
piercemoore / Nil.sublime-theme
Created March 21, 2013 21:28
Compressed sidebar modification for Sublime Text 2 theme "Nil". This modification reduces the indentation, row padding, and font sizes for the Nil theme to make it easier to work with large numbers of files.
[
// Nil theme for Sublime Text 2
// https://github.com/nilium/st2-nil-theme
// TABS
// ==========================================================
// - Tabset
@piercemoore
piercemoore / UnderscoreMixins.js
Last active December 15, 2015 15:49
Compilation of Awesome and Mega-Useful Underscore.js Mixins
/**
* All of the following Mixins are credited to their original authors, I DID NOT write ANY of these awesome things
* unless I specifically commented immediately preceding the mixin.
*/
// underscore-pickrandom.js
// (c) 2012 Simon Kågedal Reimer
// This file is freely distributable under the MIT license.
// https://gist.github.com/skagedal/1709989
@piercemoore
piercemoore / MongoShellScripts.js
Last active December 15, 2015 16:09
MongoDB Shell Scripts to make your doggone life easier
/**
* Links and such
*
* http://docs.mongodb.org/manual/reference/mongo-shell/
* http://docs.mongodb.org/manual/reference/javascript/
* http://docs.mongodb.org/manual/reference/meta-query-operators/
*/
/**
* Show the names of all collections and the number of documents in each of them.
@piercemoore
piercemoore / _foundicons.scss
Created April 25, 2013 06:21
Wrap all foundation's icon fonts into one file include
// Let's wrap all these into the same file :D
@mixin i-class($name,$pua) {
.#{$classPrefix}#{$name}:before {
content: "\f#{$pua}";
}
}
@mixin ie-class($name,$pua) {
.#{$classPrefix}#{$name} {