Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| <?php | |
| require("postmark.php"); | |
| $postmark = new Postmark("your-api-key","from-email","optional-reply-to-address"); | |
| if($postmark->to("[email protected]")->subject("Email Subject")->plain_message("This is a plain text message.")->send()){ | |
| echo "Message sent"; | |
| } | 
| #!/usr/bin/env ruby | |
| class Color < Struct.new(:r, :g, :b, :a) | |
| def self.from_hex (str) | |
| args = case str.length | |
| when 3; str.scan(/[0-9a-f]/i).map{ |s| "#{s}#{s}".to_i(16) } | |
| when 6; str.scan(/[0-9a-f]{2}/i).map{ |s| s.to_i(16) } | |
| else [0, 0, 0] | |
| end << 1.0 | |
| new(*args) | 
| #!/usr/bin/env ruby | |
| # watch.rb by Brett Terpstra, 2011 <http://brettterpstra.com> | |
| # with credit to Carlo Zottmann <https://github.com/carlo/haml-sass-file-watcher> | |
| # original by Brett Terpstra <http://brettterpstra.com/watch-for-file-changes-and-refresh-your-browser-automatically/> | |
| # fork by Vaclav Vancura / SAY Media <http://saymedia.com> | |
| trap("SIGINT") { exit } | |
| filetypes = ['less'] | |
| watch_folder = 'content/media/less' | 
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000A Modified function of Paul Irish's StaticServer shell function, according to this gist You can run static servers for many languages.
$ staticServer <lang> <port> #port is optional, default is 8000| // Determine if an element is in the visible viewport | |
| function isInViewport(element) { | |
| var rect = element.getBoundingClientRect(); | |
| var html = document.documentElement; | |
| return ( | |
| rect.top >= 0 && | |
| rect.left >= 0 && | |
| rect.bottom <= (window.innerHeight || html.clientHeight) && | |
| rect.right <= (window.innerWidth || html.clientWidth) | |
| ); | 
To answer this StackOverflow question I wrote this — a small solution based on a never-rendered <canvas> element. It fills a 1-pixel canvas with the provided fill-style, and then reads the RGBA values of that pixel. It will work with any CSS color -- name, rgba(), hex, or even something more exotic like a gradient or pattern. Invalid colors are always returned as transparent black. Transparent colors are treated as painted on a newly-cleared canvas.
It's been tested in modern-ish versions of IE, Chrome, Safari, and Firefox. The API is:
color_convert.to_hex(color)   # Converts color to a hex-based RGB triple; to_hex('red') returns '#ff0000'
color_convert.to_rgba(color)  # Converts color to an rgba() string; to_rgba('red') returns 'rgba(255,0,0,1)'
| // Fullscreen controller used on www.windy.com | |
| const d = document | |
| , el = $('#fullscreen') | |
| , isFullscreen = () => d.fullscreen || d.webkitIsFullScreen || d.mozFullScreen | |
| , onFullChange = () => el.innerHTML = isFullscreen() ? '' : '-' // Change of icon | |
| d.addEventListener('fullscreenchange', onFullChange ) | |
| d.addEventListener('webkitfullscreenchange',onFullChange ) | |
| d.addEventListener('webkitfullscreenchange',onFullChange ) | |
| d.addEventListener('mozfullscreenchange',onFullChange ) |