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
| # Implementation | |
| pre = (fn, error_handler, great) -> | |
| fn() | |
| errors = req.validationErrors() | |
| if errors | |
| v(errors) for k,v of error_handler | |
| else | |
| v() for k,v of great | |
| # Result |
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
| <div id='cptup-ready'></div> | |
| <script type='text/javascript'> | |
| (function() { | |
| var cpt = document.createElement('script'); | |
| cpt.type = 'text/javascript'; | |
| cpt.async = true; | |
| cpt.src = 'http%s://captainup.com/assets/embed.js'; | |
| cpt.src.replace('%s', (location.protocol == 'https:' ? 's' : '')); | |
| (document.getElementsByTagName('head')[0] || | |
| document.getElementsByTagName('body')[0]).appendChild(cpt); |
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
| up: (o) -> | |
| tasks = _cpt.topics.concat o | |
| if @initialized # Everything is loaded and we are good to go | |
| while tasks.length | |
| task = tasks.shift() | |
| if @is_function(task) then task() | |
| else @[k](v) for k,v of task | |
| else | |
| # search for the initialization object (the one with the api key) |
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
| pre = (req, fn, next) -> | |
| error_handler = fn() | |
| errors = req.validationErrors() | |
| if errors then error_handler(errors) | |
| else next() |
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
| @get '/health', -> | |
| pre @req, => | |
| @req.assert('param', 'Invalid Param').notEmpty() | |
| @next | |
| , => | |
| # Validation Passed | |
| @response.json | |
| pid: process.pid | |
| memory: process.memoryUsage() | |
| uptime: process.uptime() |
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
| create_job = (klass, args) -> | |
| job = JSON.stringify | |
| class: klass | |
| args : args | |
| redis.multi() | |
| .sadd('resque:mysite:tasks:queues', 'facebook') | |
| .rpush('resque:mysite:tasks:queue:facebook', job) | |
| .exec() | |
| create_job "MySite::GetFacebookFriends", [fb_id] |
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
| # Parses a URL string, using the DOM | |
| # | |
| # - href - full URL | |
| # - host - sub.domain.tld:port | |
| # - path - /stuff | |
| # - protocol - https: | |
| # - port - 80 | |
| # - search - unparsed query string | |
| # - query - parsed query string | |
| # - fullpath - path + query string |
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
| # A wrapper around the morpheus animation library, | |
| # for a jQuery like syntax. Passing the duration | |
| # and callback can work as separate arguments or as | |
| # part of the options object. | |
| # | |
| # Easings can be specified by just writing their name. | |
| # | |
| # - o - the options bag, exactly like morpheus. | |
| # Remember to add easings, as it defaults | |
| # to easeOut. |
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
| # A very ugly hack to access object literals | |
| # with the fat arrow: | |
| # | |
| # _this = obj = {} | |
| # | |
| # $.extend obj, | |
| # hello: => @stuff() | |
| # | |
| # compiles to: | |
| # |
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
| # Mixins | |
| # ------------------------------- | |
| # Adapted from The Little Coffee Book | |
| # http://arcturo.github.com/library/coffeescript/03_classes.html | |
| # and this gist: | |
| # https://gist.github.com/993415 | |
| moduleKeywords = ['extended', 'included', 'setup'] | |
| class Module |