This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| //dynamically generated by ASP.NET for the language passed in. | |
| var labels = { | |
| language: 'English', | |
| objectOverlay: { | |
| closeX: 'Close X', | |
| fallback: 'Video for {vid}' | |
| }, | |
| global: { | |
| label1: 'label1', | |
| label2: 'label2' |
| // Did you mean return false? | |
| // 'return false' stops the default behavior of the event | |
| // and prevents it from bubbling up DOM, which kills | |
| // event delegation and may not be what you indented. | |
| // Learn how these event methods can fine tune your | |
| // event handler functions. | |
| $("#clickme").click(function(e) { | |
| //Prevent the default click action from firing. |
| FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *_svn*') DO RMDIR /S /Q "%%G" | |
| FOR /F "tokens=*" %%G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%%G" |
| if (!navigator.geolocation) { | |
| navigator.geolocation = (function (window) { | |
| function getCurrentPosition(callback) { | |
| // NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random | |
| // source: http://www.maxmind.com/app/javascript_city | |
| // The source is open source, as per: http://www.maxmind.com/app/api, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet! | |
| var geourl = 'http://j.maxmind.com/app/geoip.js_' + Math.random(), | |
| iframe = document.createElement('iframe'), | |
| doc, win; |
| if (!navigator.geolocation) { | |
| navigator.geolocation = (function (window) { | |
| function getCurrentPosition(callback) { | |
| // NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random | |
| // source: http://www.maxmind.com/app/javascript_city | |
| // The source is open source, as per: http://www.maxmind.com/app/api, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet! | |
| var geourl = 'http://j.maxmind.com/app/geoip.js_' + Math.random(), | |
| iframe = document.createElement('iframe'), | |
| doc, win; |
| var to12Hr = function(n, r /* round to nearest r minutes */) { | |
| if (!n || n >= 24) return '12:00 AM'; | |
| var m = (Math.round(n%1*(r = (r ? 60/r : 60)))/r)*60; | |
| return ((n = (m>59 ? n+1 : n))>=13 ? (n|0)-12 : n|0) + ':' + (m>9 ? (m>59 ? '00' : m) : '0'+m) + (n>=12 && m<60 ? ' PM' : ' AM'); | |
| } | |
| // to12Hr(6.5) => "6:30 AM" | |
| // to12Hr(13.19) => "1:11 PM" | |
| // to12Hr(13.19, 15) => "1:15 PM" (rounds to 15 mins) |