By Henry Blyth
Uses Markdown Preview by [@revolunet][], and the fantastic [Gistdeck][] by [@nzoschke][] and [@seaofclouds][].
- [Sublime Text 2][sublime] (ST2)
- [Markdown Preview ST2 package, my custom fork][md preview]
| // Difference in map between underscore/lodash and jQuery/Zepto. | |
| // | |
| // $ allows filtering at the same time; _ does not. | |
| // | |
| // In your client-side JavaScript apps that use _ and $, this can come as a | |
| // surprise since the assumption is that all your map, each, filter, etc. needs | |
| // are fulfilled by _, and you'd be right to use them for speed since they | |
| // alias native methods where available. However, sometimes $ can be useful, | |
| // and this is one such case where that's true. | |
| // |
| { | |
| "auto_complete_commit_on_tab": true, | |
| "bold_folder_labels": true, | |
| "ensure_newline_at_eof_on_save": true, | |
| "folder_exclude_patterns": | |
| [ | |
| ".svn", | |
| ".git", | |
| ".hg", | |
| "CVS", |
| module.exports = (grunt) -> | |
| coffeeDir = 'coffee/' | |
| jsDir = 'project/' | |
| grunt.initConfig | |
| coffee: | |
| project: | |
| expand: true | |
| cwd: coffeeDir |
| # Split selectors that are too long so IE8 doesn't ignore them. | |
| on_stylesheet_saved do |path| | |
| CssSelectorSplitter.split(path) unless path[/\d+$/] | |
| end | |
| # The following is a default config.rb created by `compass create`. | |
| # Set this to the root of your project when deployed: | |
| http_path = "/" | |
| css_dir = "stylesheets" |
| (function() { | |
| function getRgbArray(color, alpha) { | |
| // Always return an array, either empty or filled. | |
| var rgb = []; | |
| var hex; | |
| // Get an array of rgb(a) values. | |
| if (color.substr(0, 1) === '#') { | |
| /* HEX STRING */ | |
| // If the first character is # we're dealing with a hex string. Get |
| (function() { | |
| function getRgbArray(color, alpha) { | |
| // Always return an array, either empty or filled. | |
| var rgb = []; | |
| var hex; | |
| // Get an array of rgb(a) values. | |
| if (color.substr(0, 1) === '#') { | |
| /* HEX STRING */ | |
| // If the first character is # we're dealing with a hex string. Get |
Anonymous functions allow us to compartmentalise our code and avoid [polluting the global scope][global scope]. The difference between using and not using an anonymous function is explained with a basic example of changing the background color to red when the DOM is ready.
Here we use the onload method of document.body.
| // Found at http://usejquery.com/posts/the-jquery-cross-domain-ajax-guide. | |
| // Modified to remove undefined variables. Docs at http://api.jquery.com/jQuery/#jQuery2 | |
| jQuery('<li/>', { //build an li element | |
| html: jQuery('<a/>', { //with an A element inside it | |
| href: 'http://henrahmagix.github.com', //set the href for the link | |
| text: 'Henrahmagix On GitHub' //and the text | |
| }) | |
| }) |
| var TimeInMinutes = function(hours, minutes) { | |
| return this.init(hours, minutes); | |
| }; | |
| TimeInMinutes.prototype = { | |
| hours: 0, | |
| minutes: 0, | |
| days: 0, | |
| time: 0, | |
| init: function(hours, minutes) { | |
| if (hours) this.hours = hours; |