Skip to content

Instantly share code, notes, and snippets.

Todd Motto toddmotto

View GitHub Profile
@toddmotto
toddmotto / *.js
Created Sep 19, 2016
Angular function arguments
View *.js
(function(A,n,g,u,l,a,r){A.GoogleAnalyticsObject=r;A[l]=A[l]||function(){
(A[l].q=A[l].q||[]).push(arguments)},A[l].l=1*new Date();a=n.createElement(g),
r=n.getElementsByTagName(g)[0];a.async=1;a.src=u;r.parentNode.insertBefore(a,r)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-XX', 'auto');
ga('send', 'pageview');
@toddmotto
toddmotto / *.md
Last active Jul 24, 2020
Component versus Directive in AngularJS
View *.md

Component versus Directive in AngularJS

.component()

Components are not "helper" methods, they are the best change in Angular 1.x since I've been using it.

What is the role of .component()?

  • Declares new HTML via a template or templateUrl
  • Should be used to create Components as part of a Component architecture
@toddmotto
toddmotto / mock-data.txt
Created Apr 20, 2016
Excel Online / Kendo Spreadsheet data
View mock-data.txt
OrderDate
Region
Rep
Item
Units
@toddmotto
toddmotto / health.md
Last active Jun 5, 2018
Eating and workout recorder
View health.md

Week 1

Weight: 12stone 5lbs / 173lbs / 78.5kg

Day Breakfast Lunch Dinner Water Snacks Workout
Monday - - - - - -
Tuesday - - - - - -
Wednesday - - - - - -
Thursday - - - - - -
@toddmotto
toddmotto / *.md
Created Sep 14, 2015
How I lost 20kg/3stone/44lbs
View *.md

Everytime I tweet about losing weight and posting images, a lot of people ask questions - so thought I'd write something decent down about what I've done so far and am currently working on.

12 months change:

Necessary changes

Step 1: Fixing your diet

My diet used to be so so bad, energy drinks, constant sugar intake. Kill that! I also used to order takeaways at least 2-3 times a week, because it was easy and the bigger you get the lazier you get from my experience.

View gist:657ba746e89025a0200b
Z21haWxpbnZpdGU#AAjWDC2eHXTaEvbWN19YkGu-csrdu0xEv0RAqZIRtXDlouoVrL9F7Hgs1ITcurRw4omVdrjPjhYFm7V2pUYPhe57u_s5KqDn7A#ZXRpdm5pbGlhbWc
@toddmotto
toddmotto / annotate.js
Created Jul 16, 2014
Angular's annotation mapping process and performance
View annotate.js
/**
* Read the post for full details, hope these comments are helpful!
* http://toddmotto.com/angular-js-dependency-injection-annotation-process
*/
function annotate(fn, strictDi, name) {
var $inject,
fnText,
argDecl,
last;
@toddmotto
toddmotto / angular.annotate.js
Created Jul 16, 2014
Angular's annotation function
View angular.annotate.js
function annotate(fn, strictDi, name) {
var $inject,
fnText,
argDecl,
last;
if (typeof fn === 'function') {
if (!($inject = fn.$inject)) {
$inject = [];
if (fn.length) {
@toddmotto
toddmotto / extend.js
Created Jun 30, 2014
Even smaller Object extend() method, with no reference cloning: http://jsfiddle.net/LR639
View extend.js
function extend (target, source) {
var a = Object.create(target);
Object.keys(source).map(function (prop) {
prop in a && (a[prop] = source[prop]);
});
return a;
};
@toddmotto
toddmotto / extend.js
Last active Aug 29, 2015
ECMAScript 5 extend(), preserves original Object values
View extend.js
function extend (target, source) {
target = JSON.parse(JSON.stringify(target));
Object.keys(source).map(function (prop) {
Object.prototype.hasOwnProperty.call(target, prop) && (target[prop] = source[prop]);
});
return target;
};
You can’t perform that action at this time.