I published this email exchange as a full post at csswizardry.com/…/can-css-be-too-modular.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('MyComponent', []) | |
| .service('MyComponent', function($log, $rootScope, $compile) { | |
| return function(params) { | |
| var scope; | |
| // Pass params through to a new'd up scope. | |
| // I'm just shoving them all in there as a property | |
| // but you could be more discreet. | |
| scope = $rootScope.$new(); | |
| scope.params = params; | |
| var directive = $compile('<my-component>')(scope); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function (window) { | |
| document.addEventListener("DOMContentLoaded", function (e) { | |
| var supports = { | |
| srcset: false, | |
| currentSrc: false, | |
| sizes: false, | |
| picture: false | |
| }; | |
| var img = new Image(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| var perfBar = function(budget) { | |
| window.onload = function() { | |
| window.performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; | |
| var timing = window.performance.timing, | |
| now = new Date().getTime(), | |
| output, loadTime; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| formatDistance, | |
| isAfter, | |
| isBefore, | |
| endOfDay, | |
| startOfDay, | |
| isSameDay, | |
| isSameSecond, | |
| isSameMinute, | |
| isSameHour, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default async function tryCatch<Data>( | |
| promise: Promise<Data>, | |
| ): Promise<{ error: Error } | { data: Data }> { | |
| try { | |
| return { data: await promise }; | |
| } catch (error) { | |
| return { error }; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- Conf -*- | |
| [color] | |
| branch = auto | |
| diff = auto | |
| status = auto | |
| showbranch = auto | |
| ui = true | |
| # color.branch | |
| # A boolean to enable/disable color in the output of git-branch(1). May be set to always, false (or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://github.com/lsmith/addBusinessDays/blob/master/addBusinessDays.js | |
| // var d = new Date(); | |
| // addBusinessDays(d, numberOfDays); | |
| function addBusinessDays(d,n) { | |
| d = new Date(d.getTime()); | |
| var day = d.getDay(); | |
| d.setDate(d.getDate() + n + (day === 6 ? 2 : +!day) + (Math.floor((n - 1 + (day % 6 || 1)) / 5) * 2)); | |
| return d; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'base64' | |
| # tools.ietf.org/html/rfc2397 | |
| # developer.mozilla.org/en/data_URIs | |
| # "data:" + MIME type + ";base64," + base64-encoded content | |
| def to_data_url(content, content_type) | |
| outuri = 'data:' + content_type + ';base64' | |
| content = Base64.encode64(content).gsub("\n", '') | |
| outuri += ",#{content}" |
OlderNewer