Skip to content

Instantly share code, notes, and snippets.

View toddmotto's full-sized avatar

Todd Motto toddmotto

View GitHub Profile
@toddmotto
toddmotto / gist:6596373
Created September 17, 2013 15:56
Disable Web Security in Chrome Canary to make cross-domain XHR requests (local servers obvs).
open -a Google\ Chrome\ Canary --args --disable-web-security
@toddmotto
toddmotto / *.md
Last active April 25, 2023 09:06
Component versus Directive in AngularJS

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 / gist:4267440
Created December 12, 2012 12:41
Kickass micro reset and helper.
*, *:after, *:before {
margin:0;
padding:0;
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-font-smoothing:antialiased;
-moz-font-smoothing:antialiased;
-o-font-smoothing:antialiased;
font-smoothing:antialiased;
@toddmotto
toddmotto / *.md
Created September 14, 2015 13:46
How I lost 20kg/3stone/44lbs

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.

@toddmotto
toddmotto / extend.js
Created June 30, 2014 12:42
Even smaller Object extend() method, with no reference cloning: http://jsfiddle.net/LR639
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 / gist:6249144
Created August 16, 2013 11:36
XAMPP svg+xml MIME Type
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/trunk/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/trunk/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
@toddmotto
toddmotto / angular.annotate.js
Created July 16, 2014 21:05
Angular's annotation function
function annotate(fn, strictDi, name) {
var $inject,
fnText,
argDecl,
last;
if (typeof fn === 'function') {
if (!($inject = fn.$inject)) {
$inject = [];
if (fn.length) {
@toddmotto
toddmotto / gist:5477991
Created April 28, 2013 18:56
Center Google Maps Marker positioning on window.resize
google.maps.event.addDomListener(window, 'resize', function() {
var center = map.getCenter()
google.maps.event.trigger(map, "resize")
map.setCenter(center)
})
@toddmotto
toddmotto / q-http.js
Created May 28, 2014 09:34
Using $q.defer() with $http in Angular to return the Promise Object only
var query = function (endpoint) {
var deferred = $q.defer();
$http.get(endpoint)
.success(function (data) {
deferred.resolve(data);
})
.error(function (data) {
deferred.reject(data);
});
return deferred.promise;
@toddmotto
toddmotto / *.js
Created September 19, 2016 19:41
Angular function arguments
(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');