Skip to content

Instantly share code, notes, and snippets.

@timgit
timgit / megaNumber.js
Last active January 15, 2020 08:35
Large number format filter for Angular written in ES6 that rounds to the specified decimal place (defaults to 1). 1 billion => 1B, 1,490,000 => 1.5M, 999,999 => 1M
angular.module('utilsModule').filter("megaNumber", () => {
return (number, fractionSize) => {
if(number === null) return null;
if(number === 0) return "0";
if(!fractionSize || fractionSize < 0)
fractionSize = 1;
var abs = Math.abs(number);
@timgit
timgit / rootScopeExtensionsModule.js
Last active June 16, 2016 14:23
Angular message bus and smartWatch
angular.module('rootScopeExtensionsModule', [])
.config($provide => {
$provide.decorator('$rootScope', $delegate => {
var rootScope = $delegate;
Object.defineProperty(rootScope.constructor.prototype, '$bus', {
get: function() {
return {
publish: (msg, data) => {
@timgit
timgit / bloggerPostBodyTruncationFragment.xml
Last active August 29, 2015 14:06
Because you really only need the body of your blog post on the post page itself
<!--
Yep, I use blogger for my blog :)
All the examples I found online used CSS, which still renders all the content and slows down the page loading
Making this change will allow you to increase the number of posts on the page without a huge page size
-->
<div class='post-body entry-content' expr:id='&quot;post-body-&quot; + data:post.id' itemprop='articleBody'>
<b:if cond='data:blog.url != data:post.url'>
<data:post.snippet /> <!-- only show snippets if not on the post page, or just delete this element to skip it entirely -->